4 ms·
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?view=netcore
by sasmithjr 7y 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?view=netcore-3.1 https://docs.microsoft.com/en-us/dotnet/api/system.decimal?v...
- ygra 7y agodecimal 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.
- knocte 7y agoYes 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.