Started by
LostInThought12
on
Topic category: Help with Minecraft modding (Java Edition)
Was trying to make a GUI Level-Up system yesterday that allows you to change your stats when I noticed that the global variables that I had set to add/subtract values with numbers that are not whole number's started giving wrong results after a few operations. For example a number that is supposed to increment by 0.5 every button press gave me values like 6.000004 and on subtraction went down to E+ values and below 0 even when I set an if condition to not decrease value if its already 0.
This is normal behavior because Java rounds decimal numbers unpredictably. If you want to use 100% accurate numbers, use whole numbers, or format number when printing to 1-2 decimal places