Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Program Not Printing Help

by no_slogan (Deacon)
on May 16, 2014 at 16:35 UTC ( [id://1086353]=note: print w/replies, xml ) Need Help??


in reply to Program Not Printing Help

Perl does its arithmetic with double-precision floating point, so you probably get 52-bit precision.

for (49..54) { $x=2**$_; $y = $x + 1.1; print $_, "\t", $y-$x; } 49 1.125 50 1 51 1 52 1 53 2 54 0

In C++, the size of integer types isn't specified, but long long is probably 64 bits.

If you want to deal with really big numbers, you need to use a package like Math::BigInt.

If you only use ++ and reverse on your "numbers", perl's increment magic will make it Just Work (TM).

$x="100000000000000000000"; $x++; print $x, "\n"; $x += 1; print $x, "\n"'; 100000000000000000001 1e+20

Replies are listed 'Best First'.
Re^2: Program Not Printing Help
by davido (Cardinal) on May 16, 2014 at 16:38 UTC

    You missed line one of his code.

    use bigint;

    bigint - Transparent BigInteger support for Perl


    Dave

      So I did.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-24 16:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found