Hi,
Hmmm ... perhaps that should be "Exasperated by" ... any grammarians out there ?

Anyway, it might not look much but the following (which applies only to 64-bit builds of perl) makes me quite angry:
use warnings; use integer; # makes no difference # 144115188075868217 == (2 ** 57) + 12345 $string1 = '144115188075868217'; $string2 = '144115188075868217crap'; $string1 += 0; { no warnings 'numeric'; $string2 += 0; } print $string1, "\n"; #prints 144115188075868217 ... correct print $string2, "\n"; # prints 144115188075868224 ... wrong
The first question:
Can someone tell me where it is documented that the strings '144115188075868217' and '144115188075868217crap' will be evaluated differently (in numeric context) on a 64-bit integer build of perl ?

The following also angers me:
use warnings; use integer; # makes no difference $num = 1.44115188075868217e17; print $num, "\n"; #prints 1.44115188075868e+017
The second question:
Is there some way (on a 64-bit integer build of perl) I can get scientific notation of 58-bit integers to DWIM ?

(Some other absurdity is in progress here, too. Although I wanted to see either 144115188075868217 or 1.44115188075868217e17 as output, I actually expected to see 1.44115188075868224e17 ... couldn't even get that much precision.)

With 32-bit builds of perl there's no problems with representing integers as doubles (since precision is never lost). But with 64-bit integer builds of perl you lose integer precision when you switch to the "double" representation ... which makes me wonder why switching to "double" representation on 64-bit integer builds of perl is given such a high priority.

We have a saying at $work regarding the wisdom of the powers that be (and which sums up perfectly our understanding of their actions):
"They know what they're doing."

For a glimpse of the real world problem:
Let's suppose there's a C library - and a perl extension that accesses that C library. The C library can return a string to perl (via XS) such as "1.44115188075868217e17". I would like to be able to convert that string to the numeric value 144115188075868217 on my 64-bit integer build of perl. I would expect that $num = "1.44115188075868217e17"; would do the trick. There's no problem with that approach regarding 32-bit integers (expressed in scientific notation) on 32-bit builds of perl but, as demonstrated above, it won't work with 64-bit integer builds. Instead I have to remove the "." and remove the "e17" (or "E17", or "e+017", etc., as the case may be). My first thought was to
$string =~ s/\.//; $string =~ s/e/crap//i;
But no ... I can't just replace the 'e'/'E' with 'crap' ... I have to remove the 'e' plus whatever follows it. (For some anal-retentive-nitpicker-type-inexplicable reason that really pisses me off.)

Ok .... so it's no big deal ... but this is perl ... where things are supposed to "just work". (And I'm hard pressed to understand why, in this particular instance, things have been designed to "just not work".)

Cheers,
Rob

In reply to Exasperated with 64-bit integer builds of perl 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, details, 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, summary, 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.