floatround()
Description
Round a floating point number to an integer value.
Syntax
floatround(value, method);
Parameters
Variable | Input |
|---|---|
| Value to round. |
| The rounding method may be one of: floatround_round - round to the nearest integer value, where a fractional part of exactly 0.5 rounds upwards (this is the default); floatround_floor - round downwards; floatround_ceil - round upwards; floatround_tozero - round downwards for positive values and upwards for negative values (“truncate”); |
Returns
The rounded value, as an integer (an untagged cell).
Function call example
Example of rounding float type numbers
new Float: data1 = 10.567;
new Float: round; // could be: new round;
main(){
round = floatround(data1, floatround_round); //the result will be: round = 11
while(1){
Delay(100);
}
}Notes and Warnings
When rounding negative values upwards or downwards, note that−2 is considered smaller than−1.