Due to floating point arithmetic, the multiplied value is not exactly 51. When I tried now, * 0.51f * 100 * gave the result 50.9999990463257.
And when you parse 50.9999990463257 and int, you will surely get 50.
If you want the calculations to be accurate, you will need to use a type of type decimalinstead float.
If you want to understand why, read the article I linked below.
What Every Computer Scientist Should Know About Floating-Point Arithmetic
source
share