Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Perl can't make some easy arithmetics :(

by Loops (Curate)
on Oct 24, 2014 at 20:52 UTC ( [id://1104918]=note: print w/replies, xml ) Need Help??


in reply to Perl can't make some easy arithmetics :(

What version of Perl are you using?

perl 5, version 18, subversion 4 (v5.18.4) on 64bit:

2 2 2 2
2 2 2 2
  • Comment on Re: Perl can't make some easy arithmetics :(

Replies are listed 'Best First'.
Re^2: Perl can't make some easy arithmetics :(
by LanX (Saint) on Oct 24, 2014 at 20:58 UTC
    Could it be you are on a 64 bit system?

    Perl automatically switches to floating point representation² if the integer range is exceeded¹.

    update

    Oh yes you did an update showing the bits :)

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)

    ¹) 2**31 < 900000000000000009 < 2**63

    ²) IIRC does Perl's FP mantissa have 56 bits so 7.2e+16 ~~ 2**56  < 900000000000000009 ~~ 9e+17

        For a total precision of 53 bits because of the implied leading 1.
Re^2: Perl can't make some easy arithmetics :(
by rsFalse (Chaplain) on Oct 24, 2014 at 21:05 UTC
    I used ideone.com for calculating. It says version is 5.16.2

      Okay, ideone.com is running on 32bit, and that is what you're running into. On my 64bit system with this input:

      9 7
      900000000000000009 900000000000000007
      99223372036854775810 99223372036854775808
      
      The output is:
      2 2 2 2
      2 2 2 2
      0 0 0 2
      
        Seems that there is a problem with magic: if use bigint and take some string, Perl doesn't convert correctly string to bigint?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2024-04-19 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found