1.5 is the Midpoint Between 0 and Infinity
summary
Claim: 1.5 is midpoint between 0 and infinity because Ruby’s range bsearch converts IEEE 754 floats into integers and bisects those bit patterns. Implementation detail: a union-based double_as_int64 reads the float bits (using reads float bits as int after fabs) so 0 and Infinity map to integer endpoints and the integer midpoint decodes to 32/64-bit float 1.5. Demo prints 1.5 then huge integers that converge to 42, proving the trick works.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:04Ruby's binary search mystery
- 2:08Linear vs binary search
- 6:01Binary search with floats
- 7:05IEEE 754 floating point
- 10:58Float to integer conversion
- 13:49Why 1.5 is the midpoint between 0 and infinity
- 15:14Why binary search works
- 16:37Ruby's range B search
- 20:08Floating point resources
- 20:50Q&A








