C
C#9mo ago
hagan

❔ Why does it do this?

I'm learning C# and this makes no sense the answer is 3.3 and that's it why does it try to exact it and make it wrong still?
No description
No description
7 Replies
Angius
Angius9mo ago
Floating point rounding errors That's just how floating points work. Not every floating point number can be represented in binary, so what we often get is the best approximation
hagan
hagan9mo ago
oh ok thank you!
Jimmacle
Jimmacle9mo ago
there is a nice tool here that you can use to experiment and see why this happens https://www.h-schmidt.net/FloatConverter/IEEE754.html
jcotton42
jcotton429mo ago
🎵 pigeon hole principle 🎵
Arch Leaders
Arch Leaders9mo ago
Decimal Struct (System)
Represents a decimal floating-point number.
jcotton42
jcotton429mo ago
decimal stil has limitations it's just much better in the precision department than float or double
Accord
Accord9mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.