Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2017-02-22 12:18 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (327 votes). Check out past polls.