Skript icon indicating copy to clipboard operation
Skript copied to clipboard

Fix rounding accuracy

Open TPGamesNL opened this issue 3 years ago • 3 comments

Description

  • Removed unused methods
  • Cleaned up file
  • Adjust rounding methods with Skript.EPSILON before handling (lines 169, 184, 199, 206, 216, 226)

Target Minecraft Versions: any Requirements: none Related Issues: #4235

TPGamesNL avatar Aug 01 '21 10:08 TPGamesNL

Well, whatever the fix, due to the limitations of floating-point numbers' representation, there will always be a "bug" somewhere.

function floor_test():
	set {_a} to 3.9999999999
	set {_b} to floor({_a})
	broadcast {_a}.toString()
	broadcast {_b}.toString()

image

Matocolotoe avatar Aug 01 '21 20:08 Matocolotoe

While you could call that behaviour a bug, 3.9999999999 = 4 according to Skript (as seen in Javadoc of Skript.EPSILON), so this is to be expected. We have to draw the line somewhere, and Njol (probs) decided 10^-10 was the width of that line

TPGamesNL avatar Aug 01 '21 20:08 TPGamesNL

Right, I guess it's still better than having inconsistencies occurring at 2 decimal places.

Matocolotoe avatar Aug 01 '21 20:08 Matocolotoe