#!/usr/bin/env ruby finish = ARGV[0] ? Float(ARGV[0]) : 2.0 format = ARGV[1] ? ARGV[1] : '%.17g' d = finish / 2 f = d 54.times do s = format % d puts "#{s} == #{"%a" % d}" raise "'#{s}'.to_f != #{"%a" % d}" if s.to_f != d exit 0 if d == finish f /= 2 d += f end
Standard input is empty
1 == 0x1p+0 1.5 == 0x1.8p+0 1.75 == 0x1.cp+0 1.875 == 0x1.ep+0 1.9375 == 0x1.fp+0 1.96875 == 0x1.f8p+0 1.984375 == 0x1.fcp+0 1.9921875 == 0x1.fep+0 1.99609375 == 0x1.ffp+0 1.998046875 == 0x1.ff8p+0 1.9990234375 == 0x1.ffcp+0 1.99951171875 == 0x1.ffep+0 1.999755859375 == 0x1.fffp+0 1.9998779296875 == 0x1.fff8p+0 1.99993896484375 == 0x1.fffcp+0 1.999969482421875 == 0x1.fffep+0 1.9999847412109375 == 0x1.ffffp+0 1.9999923706054688 == 0x1.ffff8p+0 1.9999961853027344 == 0x1.ffffcp+0 1.9999980926513672 == 0x1.ffffep+0 1.9999990463256836 == 0x1.fffffp+0 1.9999995231628418 == 0x1.fffff8p+0 1.9999997615814209 == 0x1.fffffcp+0 1.9999998807907104 == 0x1.fffffep+0 1.9999999403953552 == 0x1.ffffffp+0 1.9999999701976776 == 0x1.ffffff8p+0 1.9999999850988388 == 0x1.ffffffcp+0 1.9999999925494194 == 0x1.ffffffep+0 1.9999999962747097 == 0x1.fffffffp+0 1.9999999981373549 == 0x1.fffffff8p+0 1.9999999990686774 == 0x1.fffffffcp+0 1.9999999995343387 == 0x1.fffffffep+0 1.9999999997671694 == 0x1.ffffffffp+0 1.9999999998835847 == 0x1.ffffffff8p+0 1.9999999999417923 == 0x1.ffffffffcp+0 1.9999999999708962 == 0x1.ffffffffep+0 1.9999999999854481 == 0x1.fffffffffp+0 1.999999999992724 == 0x1.fffffffff8p+0 1.999999999996362 == 0x1.fffffffffcp+0 1.999999999998181 == 0x1.fffffffffep+0 1.9999999999990905 == 0x1.ffffffffffp+0 1.9999999999995453 == 0x1.ffffffffff8p+0 1.9999999999997726 == 0x1.ffffffffffcp+0 1.9999999999998863 == 0x1.ffffffffffep+0 1.9999999999999432 == 0x1.fffffffffffp+0 1.9999999999999716 == 0x1.fffffffffff8p+0 1.9999999999999858 == 0x1.fffffffffffcp+0 1.9999999999999929 == 0x1.fffffffffffep+0 1.9999999999999964 == 0x1.ffffffffffffp+0 1.9999999999999982 == 0x1.ffffffffffff8p+0 1.9999999999999991 == 0x1.ffffffffffffcp+0 1.9999999999999996 == 0x1.ffffffffffffep+0 1.9999999999999998 == 0x1.fffffffffffffp+0 2 == 0x1p+1