Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-19 09:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found