~/talk

1.5 is the Midpoint Between 0 and Infinity

Talkat RubyConf 2022 · 2022-11-29..12-01· [ruby]
slides:none on file

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

  1. 0:00Introduction
  2. 1:04Ruby's binary search mystery
  3. 2:08Linear vs binary search
  4. 6:01Binary search with floats
  5. 7:05IEEE 754 floating point
  6. 10:58Float to integer conversion
  7. 13:49Why 1.5 is the midpoint between 0 and infinity
  8. 15:14Why binary search works
  9. 16:37Ruby's range B search
  10. 20:08Floating point resources
  11. 20:50Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.