Link Search Menu Expand Document

Fixed.Round method

Explanation Returns the rounded object of the specified parameter as a Fixed object.
This method is a static method. It can be called without creating an object.
The rounding of the Fixed.Round method (when the number of digits = 0) is the maximum (positive direction) of the integers of the value +0.5 or less.
Call format var f = Fixed.Round ( n [, d ])
Return value Rounded value ( Fixed object)
Arguments n Specify the number to be rounded as Fixed type, Number type, or String type.
integer d Specify the digit you want to round.
It can be specified by -14 to 3.
0 is rounded to the nearest whole number, and 3 is rounded to the third decimal place.
If it is a negative number, it will be specified in the direction of the integer value. If omitted, it is 0.
Exception None
Example of use
print (Fixed.Round (12345.678F, -2)); / * 12300 * /
print (Fixed.Round (12345.678F));      / * It becomes 12346 * /
print (Fixed.Round (12345.678F, 2));   / * It becomes 12345.68 * /
 
print (Fixed.Round (0.49F));   / * 0 * /
print (Fixed.Round (0.50F));   / * 1 * /
print (Fixed.Round (0.51F));   / * 1 * /
print (Fixed.Round (-0.49F)); / * 0 * /
print (Fixed.Round (-0.50F)); / * 0 * /
print (Fixed.Round (-0.51F)); / * -1 * /
Related item