We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Floats don't give you accuracy. If you want to have accuracy in your division when there is a remainder with integer division, you have to use a BCD (binary coded decimal) or other format. In C# you can use decimal.
However, if you are going to cast back to a long then you might as well use integer division. Casting just truncates, it does not round.
Bill Division
You are viewing a single comment's thread. Return to all comments →
Floats don't give you accuracy. If you want to have accuracy in your division when there is a remainder with integer division, you have to use a BCD (binary coded decimal) or other format. In C# you can use decimal. However, if you are going to cast back to a long then you might as well use integer division. Casting just truncates, it does not round.