Help for this page

Select Code to Download


  1. or download this
    for my $a (-2..10, 0.2, -0.2, 1 + 0.25e-15) {  
            $_ = unpack("b*", pack("d", $a));   # double to bit-pattern 
    ...
            s/^(..)(.{12})(.*)/Sgn:$1  Exp: $2  Mant:(1,)$3/; 
            print "$a\t -- $_\n";
    }
    
  2. or download this
    my $a = 1+0.25e-15;# hidden bit and last bit of mantissa: 1
    print "Test                : is int.?   correct?\n";
    ...
    abs(a-int(a) < 1e-15: yes        no!
    abs(a-int(a) > 0    : no         yes
    epsilon < 2.22045e-16 required (here!)