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
Issue description:
If you assign an int var with INF, it gets initialized as the min int (-9223372036854775808) which is not useful as it is a negative value. If we are not meant to assign INF to an int then the docs should have a warning on it.
I haven't tested this using floats btw.
Steps to reproduce:
var int_inf : int = INF
var casted_int_inf = int(INF)
var as_inf = INF as int
var untyped_inf = INF
print(int_inf) # -9223372036854775808
print(casted_int_inf) # -9223372036854775808
print(as_inf) # -9223372036854775808
print(untyped_inf) # 1.#INF
print(1 > INF) # False. Ok
print(1 > int_inf) # True. Not ok.
print(1 > casted_int_inf) # True. Not ok.
print(1 > as_inf) # True. Not ok.
print(1 > untyped_inf) # False. Ok.
print(INF == INF) # True. Duh :P
print(INF == int_inf) # True. But what about if I wanted to check a negative INF ?
print(INF == casted_int_inf) # True. Same as above.
print(INF == as_inf) # True. Same as above.
print(INF == untyped_inf) # False. Huh?
The text was updated successfully, but these errors were encountered:
If we are not meant to assign INF to an int then the docs should have a warning on it.
AFAIK this type of cast is passed directly to underlying C cast, and casting NaN to integer is undefined behavior in C. Debug builds probably should have some check.
6.3.1.4 Real floating and integer: When a finite value of real floating type is converted to an integer type other than_Bool, the fractional part is discarded (i.e., the value is truncated toward zero). If the value ofthe integral part cannot be represented by the integer type, the behavior is undefined.
print(INF == untyped_inf) # False. Huh?
That's correct, comparison with a NaN always return false when comparing with itself (or with anything else), there are is_nan and is_inf function to check if variable is Inf.
Godot version:
3.1.1.stable.official
OS/device including version:
Windows 7
Issue description:
If you assign an
int var
withINF
, it gets initialized as the minint
(-9223372036854775808) which is not useful as it is a negative value. If we are not meant to assignINF
to anint
then the docs should have a warning on it.I haven't tested this using floats btw.
Steps to reproduce:
The text was updated successfully, but these errors were encountered: