Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Once you phrased it this way, I realized you finally gave me an in-the-wild use-case for my Data::IEEE754::Tools. Thanks! :-)

#!/usr/bin/env perl use strict; use warnings; use Data::IEEE754::Tools qw/ulp/; sub uv_fits_double_using_ulp { 0 == ($_[0] % ($_[0]/ulp($_[0]))) } my @in = map { no warnings 'portable'; chomp; oct('0b'.$_) } <DATA>; for(@in) { my $d = $_/ulp($_); printf "%-24s: %4d %32.15f %16d %1s\n", $_, ulp($_), $_/ulp($_), $ +_ % $d, uv_fits_double_using_ulp($_) ? 'T' : 'F'; } __END__ 1111111111111111111111111111111111111111111111111111100000000000 1111111111111111111111111111111111111111111111111111110000000000 1111111111111111111111111111111111111111111111111111100000000001 1111111111111111111111111111111111111111111110011011100000000000 1111111111111111111111111111111111111111111111111111100000000000 0111111111111111111111111111111111111111111111111111110000000000 0011111111111111111111111111111111111111111111111111111000000000 0001111111111111111111111111111111111111111111111111111100000000 0000111111111111111111111111111111111111111111111111111110000000 0000011111111111111111111111111111111111111111111111111111000000 0000001111111111111111111111111111111111111111111111111111100000 0000000111111111111111111111111111111111111111111111111111110000 0000000011111111111111111111111111111111111111111111111111111000 0000000001111111111111111111111111111111111111111111111111111100 0000000000111111111111111111111111111111111111111111111111111110 0000000000011111111111111111111111111111111111111111111111111111 0000000000111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111111
which gives
18446744073709549568 : 2048 9007199254740991.000000000000000 + 0 T 18446744073709550592 : 4096 4503599627370496.000000000000000 450359 +9627369472 F 18446744073709549569 : 2048 9007199254740991.000000000000000 + 1 F 18446744073709139968 : 2048 9007199254740791.000000000000000 + 0 T 18446744073709549568 : 2048 9007199254740991.000000000000000 + 0 T 9223372036854774784 : 1024 9007199254740991.000000000000000 + 0 T 4611686018427387392 : 512 9007199254740991.000000000000000 + 0 T 2305843009213693696 : 256 9007199254740991.000000000000000 + 0 T 1152921504606846848 : 128 9007199254740991.000000000000000 + 0 T 576460752303423424 : 64 9007199254740991.000000000000000 + 0 T 288230376151711712 : 32 9007199254740991.000000000000000 + 0 T 144115188075855856 : 16 9007199254740991.000000000000000 + 0 T 72057594037927928 : 8 9007199254740991.000000000000000 + 0 T 36028797018963964 : 4 9007199254740991.000000000000000 + 0 T 18014398509481982 : 2 9007199254740991.000000000000000 + 0 T 9007199254740991 : 1 9007199254740991.000000000000000 + 0 T 18014398509481983 : 4 4503599627370496.000000000000000 450359 +9627370495 F 18446744073709551615 : 4096 4503599627370496.000000000000000 450359 +9627370495 F

I doubt it's faster than some of hte others


In reply to Re^4: Detecting whether UV fits into an NV by pryrt
in thread Detecting whether UV fits into an NV by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (5)
    As of 2020-11-29 11:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?