You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you try this function at positive values - everything is ok, but at negative values you get:
floatfract(0.000000) = 0.000000; ok
floatfract(-0.200000) = 0.800000; instead of -0.2
floatfract(-0.500000) = 0.500000; instead of -0.5
floatfract(-0.800000) = 0.199999; instead of -0.2
floatfract(-1.000000) = 0.000000; ok
floatfract(-1.300000) = 0.699999; instead of -0.7
floatfract(-1.500000) = 0.500000; instead of -0.5
floatfract(-1.800000) = 0.199999; instead of -0.2
floatfract(-1.899999) = 0.100000; instead of -0.1
floatfract(-2.000000) = 0.000000; ok
floatfract(-2.100000) = 0.899999; instead of -0.9
Note
By definition "whole_value = truncated_value +fractional_value".
There is also reason in fact of inaccurate definition of floatfract (it is exist another 2 ways to get fractional part).
The text was updated successfully, but these errors were encountered:
While I agree that those results look wrong, I'm not sure your versions are better. Surely the fractional part of -1.80 is -0.80 not 0.2 (current) or -0.2 (yours).
Abstract
The floatfract(Float:value); function is most likely implemented in backend (C) as
Which is incorrect when value is negative.
The proper way is (c):
or (Pawn):
Proof/Issue reason
When you try this function at positive values - everything is ok, but at negative values you get:
Note
By definition "whole_value = truncated_value +fractional_value".
There is also reason in fact of inaccurate definition of floatfract (it is exist another 2 ways to get fractional part).
The text was updated successfully, but these errors were encountered: