Hacker News new | ask | show | jobs
by sasmithjr 2336 days ago
Look at the decimal type; it's less performant, but you'll avoid floating point issues.

https://docs.microsoft.com/en-us/dotnet/api/system.decimal?v...

2 comments

Yes I know the decimal type and it's what I use in all my code, I just thought the default would be something with more precision than double/float even if not decimal.
decimal is still floating-point, just decimal floating-point instead of binary. Things like 1/3 can still not be represented exactly. It's just that for values given in base 10 there's no transformation of the representation and 0.3 remains exactly 0.3.