-
Notifications
You must be signed in to change notification settings - Fork 126
Converting float to Fix64 consistent across CPU architectures? #23
Comments
This is the code that does it: public static explicit operator Fix64(float value)
{
return new Fix64((long)(value * ONE));
} Two things happen:
The multiplication must be deterministic because the constant is a power of two (so it amounts to incrementing the exponent on the result). So, I don't see how that wouldn't be deterministic. |
Well, except maybe for #9 It's been so long I don't really recall what the exact issue was. Just because that behavior is unspecified doesn't mean it actually varies across architectures. |
Totally makes sense. Thanks for the prompt response! |
I needed this information too. I'm going to ship my product with FixedMath assuming that casting to and from floats are deterministic. |
There's an open issue about this, but I'm not willing to put in the time to research how to best address it. |
Probably a dumb question but -
Would converting from a float to a Fix64 be consistent across CPU architectures?
The text was updated successfully, but these errors were encountered: