Floating-point values cannot accurately represent all possible numbers, so your numbers are getting closer. This leads to different results when used in the calculations.
If you need to compare floating point numbers, you should always use a small epsilon value, not equality testing. In your case, I would round to the nearest integer (without rounding down), subtract from the original value and compare the abs () of the result with epsilon.
If the question is why the amount is different, the simple answer is that they are different amounts. For a more detailed explanation, the actual representations of numbers are given here:
org: 4.5999999999999996 = 0x12666666666666 * 2^-50 ddd: 0.10000000000000001 = 0x1999999999999a * 2^-56 1/ddd: 10 = 0x14000000000000 * 2^-49 org * (1/ddd): 46 = 0x17000000000000 * 2^-47 org / ddd: 45.999999999999993 = 0x16ffffffffffff * 2^-47
You will see that no input value is exactly represented in double, each of which is rounded up or down to the nearest value. org rounded since the next bit in the sequence will be 0. ddd was rounded because the next bit in this sequence will be 1.
Because of this, when mathematical operations are performed, rounding can either be canceled or accumulated depending on the operation and how the original numbers were rounded.
In this case, 1 / 0.1 is rounded neatly back exactly to 10.
Multiplying org by 10 rounds off.
The division of org into ddd is rounded (I say happens, but you divide the rounded number by the rounded number, so it’s natural that the result is less).
Different inputs will rotate in different ways.
This is only one bit of error that can be easily ignored even with small epsilon.