My understanding may be flawed here, but if the rational type still fits in 64 bits then the smallest non-zero should be ~1/(2^64). How do you handle the case where you have more that 64 insertions between two indices?
Example:
Suppose I have three items, A, B, and C with indices 0, 1, and 2 respectively. If I reorder C to be between A and B by calling rational_intermediate(0, 1) then C should now have an index of 1/2. If I then reorder B to be between A and C with rational_intermediate(0, 1/2) then B should now have an index of 1/4. Each time this operation is performed the middle index will be (1/2)^n
What happens if I perform this swap and more than 64 times? Won't the rational run out of resolution? Is there a standard practice for renormalizing indices when an index would be below the precision that a 64 bit rational can represent?
My understanding may be flawed here, but if the rational type still fits in 64 bits then the smallest non-zero should be ~1/(2^64). How do you handle the case where you have more that 64 insertions between two indices?
Example:
Suppose I have three items,
A
,B
, andC
with indices 0, 1, and 2 respectively. If I reorderC
to be betweenA
andB
by callingrational_intermediate(0, 1)
thenC
should now have an index of 1/2. If I then reorderB
to be betweenA
andC
withrational_intermediate(0, 1/2)
thenB
should now have an index of 1/4. Each time this operation is performed the middle index will be (1/2)^nWhat happens if I perform this swap and more than 64 times? Won't the rational run out of resolution? Is there a standard practice for renormalizing indices when an index would be below the precision that a 64 bit rational can represent?