in reply to Re: How to store all 1 s in perl
in thread How to store all 1 s in perl

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: How to store all 1 s in perl
by AnomalousMonk (Archbishop) on Apr 08, 2021 at 02:02 UTC

    Win8 Strawberry 5.8.9.5 (32) Wed 04/07/2021 21:57:03 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings -l my $value = 1 x 131; print 'A: ', $value; my $value1 = $value / 1; print 'B: ', $value1; ^Z A: 1111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111 1111111111111111111111111111111111 B: 1.11111111111111e+130
    See perlop for precedence (update: and associativity, which is the critical consideration in this case) of x (string) and / (numeric) operators.

    Update: Another way to look at it:

    Win8 Strawberry 5.8.9.5 (32) Wed 04/07/2021 21:58:47 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings -l my $value = 1 x (131 / 1); print 'C: ', $value; ^Z C: 1111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111 1111111111111111111111111111111111
    (Sorry about the wrap-around. :)


    Give a man a fish:  <%-{-{-{-<

      Please, don't feed the troll.