in reply to Unpack weirdness


It looks like a bug:
$ perl5.6.0 -le 'print unpack "w", pack "w", 2**32' 2082834 $ perl5.7.2 -le 'print unpack "w", pack "w", 2**32' 4294967296

--
John.

Replies are listed 'Best First'.
Re: Unpack weirdness
by Abigail-II (Bishop) on May 30, 2002 at 15:29 UTC
    I do get the same results for 5.6.0 and 5.7.2, but if I go further back in time, I get different results. Note that 2 ** 32 is bigger than what fits in a 32 bit integer, so it could matter whether your version of Perl stores the value in an 64 integer, or a double.

    What follows are result of

    print unpack "w*", pack "w*", 2 ** 32;

    of all versions of Perl since 5.003_07 (the first version that produces any output).

    Abigail

      Just out of curiousity, could you go into the set up that produced these results? I'm imagining something in which you just type a few simple commands on a script and blammo.
      ()-()
       \"/
        `                                                     
      
        I just typed in:
        ~/Perl/runall /tmp/pack.pl
        and that would run the program /tmp/pack.pl on all versions released of Perl since 5.000. But I'm working on going back all the way to 1.000.

        Abigail