RoundLimits

 

Contents

Description

Similar to LabTalk limit -r command, to round a set of min, max and increment values

Syntax

int RoundLimits( double * pmin, double * pmax, double * pinc, int nSteps = 8, int nType = LINEAR_SPACE )

Parameters

pmin
[modify] pointer to the min value
pmax
[modify] pointer to the max value
pinc
[modify] pointer the the increment value
nSteps
[input only] 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
nType
[input only] rounding with the specific space type which belongto SPACEID,like LINEAR_SPACE...etc

Return

If this function success, the return value is the number of steps determined after the rounding, otherwise a negative value will be returned.

Examples

EX1

void RoundLimits_ex1()
{
    double x1 = -23.4;
    double x2 = 235.89;
    double xinc;
    int nSteps = RoundLimits(&x1, &x2, &xinc);
    printf("After rounding, the result is %d divisions, from %f to %f with an increment of %f\n", nSteps, x1, x2, xinc);
    // we next force increment to a particular value to redo rounding
    xinc = 50;
    nSteps =RoundLimits(&x1, &x2, &xinc, 0);
    printf("Forcing increment to be 50, the result is %d divisions, from %f to %f with an increment of %f\n", nSteps, x1, x2, xinc);
}

Remark

See Also

RoundBinningRange

header to Include

origin.h

Reference