Exact floating-point number #7277
-
Is there a way to accurately represent floating-point numbers in C#? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
All floating point numbers should have an exact and accurate representation in C#. These should roundtrip perfectly (any FP number should have an exact/accurate representation in C# that you can be certain will give you that exact FP value at runtime). This shoudl apply to both floats and doubles. |
Beta Was this translation helpful? Give feedback.
-
Isn't the answer here the |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
BitConverter.UInt64BitsToDouble()
is my preferred solution when I need to ensure the bit pattern mydouble
should have.