Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* round() without the loss of accuracy with huge numbers
- Test code:
- show_message(round(600851475143)); //WRONG
- show_message(Round(600851475143)); //RIGHT
- This script also avoids the GM bug where round(0.5) = 0
- Now, Round(0.5) = 1 like it should.
- */
- var frc;
- frc = frac(argument0);
- if (frc >= 0.5)
- return argument0 - frc + 1;
- else if (frc <= -0.5)
- return argument0 - frc - 1;
- else
- return argument0 - frc;
Advertisement
Add Comment
Please, Sign In to add comment