Advertisement
bobmarley12345

fast Round(value, places) without actually rounding

Aug 19th, 2022
870
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.21 KB | None | 0 0
  1. public static double round(double value, int places) {            
  2.     double placePower = POW_TABLE[places];
  3.     int intValue = (int) value;
  4.     return intValue + (int) (placePower * (value - intValue)) / placePower;
  5. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement