Round a set of min, max and increment values. The range is defined by pMin and pMax,
divide the given range, round the increment and the range [pMin, pMax].
int ocmath_round_range( double * pMin, double * pMax, double * pInc, int nSteps = 8 )
- [modify] pointer to the min value
- [modify] pointer to the max value
- [modify] pointer the the increment value
- [input] number of steps to divide the given range roughly defined by pmin and pmax.
- If you know the increment and do not want it to be changed, pass 0 for steps.
- Its default value is 0.
If this function success, the return value is the number of steps determined after the rounding;
otherwise a negative error code will be returned.
double x1 = -23.4;
double x2 = 235.89;
double xinc = 9.9;
int nSteps = ocmath_round_range(&x1, &x2, &xinc, 8);
printf("After rounding, the result is %d divisions, from %f to %f with an increment of %f\n", nSteps, x1, x2, xinc);
// Output of example:
// After rounding, the result is 27 divisions, from -30.000000 to 240.000000 with an increment of 10.000000
Header to Include