in reply to Re^2: Exasperated with 64-bit integer builds of perl
in thread Exasperated with 64-bit integer builds of perl

"use integer;" works on fixed point values INDEPENDENTLY of how many bits the machine has or how many bits are needed to represent a given value. Limiting it to fixed point assures that the functionality is injective. What you are asking for would downgrade it to non-injective, i.e. would make it work and not work according to a bits-needed comparison between a) the value being operated on and b) the size of the registers in the machine.

I have meanwhile thought of another way to get what you want: sprintf. If the number is floating point, it internally uses the C sprintf, thereby achieving much high performance for your requirement than changing the meaning of use integer ever could anyway.

__________________________________________________________________________________

^M Free your mind!

  • Comment on Re^3: Exasperated with 64-bit integer builds of perl

Replies are listed 'Best First'.
Re^4: Exasperated with 64-bit integer builds of perl
by syphilis (Archbishop) on May 31, 2007 at 07:53 UTC
    I have meanwhile thought of another way to get what you want: sprintf

    I don't quite follow. At its simplest, what I want is to have a string like '1.44115188075868217e17' converted to the numeric value 144115188075868217 on a use64bitint build of perl that doesn't have long doubles. I can't see a way of doing that using (s)printf. I find that printf "%d", '1.44115188075868217e17' produces 144115188075868224. Sorry if I've missed the point. (I do that sometimes :-)

    By looking at the sign, mantissa, and exponent it's not all that difficult to get the required result - and that's pretty much how I'll be doing it. Thanks Moron.

    Cheers,
    Rob
      I should have mentioned pack("Q", $string) first - but I can't recompile Perl in 64 bits here in the office to test it anyway :(
      __________________________________________________________________________________

      ^M Free your mind!

        I should have mentioned pack("Q", $string)

        Doesn't seem to DWIM:
        C:\_64>perl -e "$_=unpack('Q',pack('Q','1.44115188075868217e+017'));pr +int" 144115188075868224 C:\_64>
        I believe it just packs the NV into the quad.

        Cheers,
        Rob