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
OS/device including version:
Windows 10 64 bit, macOS 10.12.6, Linux 4.15.17
Issue description:
The same instructions give different results in Linux compared to Windows and macOS.
The following:
var v1 = Vector2(0, 1)
var op1 = int(v1.x + v1.y)
var v2 = Vector2(0, 1).normalized()
var op2 = int(v2.x + v2.y)
print("%s: %s %s: %s"%[v1, op1, v2, op2])
outputs (0, 1): 1 (0, 1): 1
on Windows and macOS,
and outputs (0, 1): 1 (0, 1): 0
on Linux.
On Linux it seems that normalized() returns a Vector2 with a Y component slightly smaller than 1, which is then truncated by the cast to int. However, the Vector2 is casted to string as if the Y value were exactly 1.
The same inconsistency appears with Vector3 too.
The text was updated successfully, but these errors were encountered:
That's simply because components of Vector2 are float, so 1.0 might be 1.00000213 or 0.99999127 depending on hardware, software, luck... So it can be that instead of 0.0 + 1.0 you get -0.00000123 + 0.9999983, which is less than 1.0 and is therefore cast to 0. The call to normalize() just adds some more precision error since it basically does 1.0 / 1.0 and 0.0 / 1.0.
Yes, float numbers are often imprecise, but numbers like 0 and 1 have exact binary representations.
There aren't non-representable values involved.
Shouldn't the above operations between the exact representations of 1 and 0 result in exact representations?
Godot version:
Godot v3.0.3.rc1.official.63e70e3
OS/device including version:
Windows 10 64 bit, macOS 10.12.6, Linux 4.15.17
Issue description:
The same instructions give different results in Linux compared to Windows and macOS.
The following:
outputs
(0, 1): 1 (0, 1): 1
on Windows and macOS,
and outputs
(0, 1): 1 (0, 1): 0
on Linux.
On Linux it seems that
normalized()
returns a Vector2 with a Y component slightly smaller than 1, which is then truncated by the cast to int. However, the Vector2 is casted to string as if the Y value were exactly 1.The same inconsistency appears with Vector3 too.
The text was updated successfully, but these errors were encountered: