Rounding to decimal places

Started by OllyWanted77 on

Topic category: Help with MCreator software

Last seen on 21:55, 29. Oct 2023
Joined Dec 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Rounding to decimal places

is there any way I can round to 1 decimal place? I've been searching for a while and I cant find anything.

Last seen on 12:02, 14. Jul 2024
Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It can be done with custom…
Thu, 10/12/2023 - 17:44

It can be done with custom code

 

DecimalFormat df = new DecimalFormet("#.#");
df.setRoundingMode(RoundingMode.HALF_UP);

YOURNUMBER = Double.parsDouble(df.format(YOURNUMBER));