Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Question on simple arithmetic using perl

by Anonymous Monk
on Sep 28, 2011 at 21:34 UTC ( #928430=note: print w/replies, xml ) Need Help??

in reply to Question on simple arithmetic using perl

When the number becomes too large for an integer it is automagically promoted to a float.

  • Comment on Re: Question on simple arithmetic using perl

Replies are listed 'Best First'.
Re^2: Question on simple arithmetic using perl
by perlbaski (Sexton) on Sep 28, 2011 at 21:43 UTC
    Thank you Monk!! So does this mean its fine to use such arithmetic and not worry about whether perl can handle it correctly?
      No. A float can represent a wider range of values, but a lesser number of significant digits than an integer.

      I'm not quite sure what the question is:

      #!/usr/bin/perl -w use strict; my $all_bits_are_on = -1; printf ("all_bits => %X\n", $all_bits_are_one); my $x = $all_bits_are_on + 1; print "Adding -1 to +1 is: $x\n"; __END__ all_bits => FFFFFFFF Adding -1 to +1 is: 0

        Note that perl is actually using long and double. On 32bit double has more significant digits than long.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928430]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2016-10-26 12:33 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (340 votes). Check out past polls.