Have you performed simple arithmetic operations like 0.1 + 0.2? You might have gotten something strange: 0.1 + 0.2 = 0.30000000000000004.
Have you performed simple arithmetic operations like 0.1 + 0.2? You might have gotten something strange: 0.1 + 0.2 = 0.30000000000000004.
That’s because the nearest representable float to 0.99999999999999 is 1.0 - not because Python is handling rationals correctly.
This is a float imprecision issue that just happens to work out in this case.
It’s worth wondering why, if Python is OK with “/“ producing a result of a different type than its arguments, don’t they implement a ratio type. e.g. https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node18.html#SECTION00612000000000000000