64-bit floating-point numbers in the IEEE 754 standard have 1 bit for the sign, 11 bits for the exponent with a bias of 1023, and 52 bits for the mantissa. The hex representation and its inverse (3!:3 and 3!:2) facilitate explorations with these numbers.

unhex=: 3!:2
hex  =: 2&(3!:3)
cons =: unhex @ ((}: hex 0.5)&,) " 1

   hex 1.5
e200000000000000
0000000000000008
0000000000000001
0000000000000000
3ff8000000000000
   unhex hex 1.5
1.5
   cons '3ff8000011112222'
1.5
   ":!.18 cons '3ff8000011112222'
1.5000000635792579

x

":!.18 cons x

        Description

 0000000000000001 

  4.9406564584124654e_324 

the smallest positive number

 8000000000000001 

 _4.9406564584124654e_324 

the largest negative number

 0000000000000000 

  0 

0

 3fefffffffffffff 

  0.99999999999999989 

the largest number less than 1

 3ff0000000000000 

  1 

1

 3ff0000000000001 

  1.0000000000000002 

the smallest number greater than 1

 3feffffffffffe00 

  0.99999999999994316 

the smallest number equal to 1 with a tolerance of 2^_44 

 3ff0000000000100 

  1.0000000000000568 

the largest number equal to 1 with a tolerance of 2^_44 

 4005bf0a8b145769 

  2.7182818284590451 

Euler's number

 400921fb54442d18 

  3.1415926535897931 

pi

 4024000000000000 

  10 

10

 4340000000000000 

  9007199254740992 

the smallest positive x such that x and x+1 have the same representation (2^53)

 baabaabaabaabaaa 

 _4.4698305231135437e_26 

sheepish number

 deadbeefdeadbeef 

 _1.2785010645440762e148 

hamburger

 7fefffffffffffff 

  1.7976931348623157e308 

the largest finite number

 ffefffffffffffff 

 _1.7976931348623157e308 

the smallest finite number

 7ff0000000000000 

  _ 

positive infinity

 fff0000000000000 

 __ 

negative infinity



Contributed by RogerHui.

Essays/IEEE Floating-Point Numbers (last edited 2008-12-08 10:45:34 by )