do I get same value if I cast to something then cast back #84064
-
if I cast int64 to uint64, do I get the same integer if I cast this uint64 to int64? I'm using F# but you can tell me about the situation in C# too if it's different What about floats |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's case by case depending on the capacity of the types.
Yes, for integers of same size, the cast is a bitcast.
Currently there's no floats with same capacity. If both types have the same base (base-2 or base-10), casting from smaller->bigger->smaller is loseless. |
Beta Was this translation helpful? Give feedback.
It's case by case depending on the capacity of the types.
Yes, for integers of same size, the cast is a bitcast.
Currently there's no floats with same capacity. If both types have the same base (base-2 or base-10), casting from smaller->bigger->smaller is loseless.
Note that this only applies for "normal' values. I'm not sure the rules about NaN/Infs.