L
LordHog
Hello all,
My lead wants to implement a data range monitor for a project that we
are coding. Basically it performs a boundry checking that will take
three parameters. I am/was trying to implement a generic data range
monitor, but it doesn't quite work. I am trying to create one method
that will accept any type of parameter and use those values whether
they be int, unsigned int, float, double etc.... I am not sure if this
can be done within the c language, but I was hoping someone might point
me in the correct direction. Thanks.
Mark
int drm( void*, void*, void*);
main( ) {
int data = 2,
lower = 5,
upper = 15;
unsigned int data2 = 1;
float data1 = 2.7f;
if ( drm( (void*)data, (void*)lower, (void*)upper ) ) {
printf( "Within bounds\n" );
} else {
printf( "Out of bounds\n" );
}
return 0;
}
bool drm( void* data, void* lowerLimit, void* upperLimit) {
if( data < lowerLimit || data > upperLimit )
return 0;
else
return 1;
}
My lead wants to implement a data range monitor for a project that we
are coding. Basically it performs a boundry checking that will take
three parameters. I am/was trying to implement a generic data range
monitor, but it doesn't quite work. I am trying to create one method
that will accept any type of parameter and use those values whether
they be int, unsigned int, float, double etc.... I am not sure if this
can be done within the c language, but I was hoping someone might point
me in the correct direction. Thanks.
Mark
int drm( void*, void*, void*);
main( ) {
int data = 2,
lower = 5,
upper = 15;
unsigned int data2 = 1;
float data1 = 2.7f;
if ( drm( (void*)data, (void*)lower, (void*)upper ) ) {
printf( "Within bounds\n" );
} else {
printf( "Out of bounds\n" );
}
return 0;
}
bool drm( void* data, void* lowerLimit, void* upperLimit) {
if( data < lowerLimit || data > upperLimit )
return 0;
else
return 1;
}