Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: (tye) BigInt usage

by ryan (Pilgrim)
on Feb 18, 2001 at 08:00 UTC ( #59201=note: print w/ replies, xml ) Need Help??


in reply to (tye)Re2: BigInt usage
in thread BigInt usage

Thanks, all is happy now. I left my first line 'ungolfed' as I actually have 7 other unrelated parameters on the command line after the two IPs.

I thought I should answer my original question about BigInt initialisation that was rightfully dispelled.

I was assuming Perl was as strongly typed as Java, and it is done a lot in Java to force data types to an outputable format from default output functions in some of the java system calls.

Java would do something like this to force an integer to a string so it can pass it to initialise a BigInt: $bigint1.new("",$integer);
In Perl there is no need, and the best thing is that BigInts can have ordinary arithmetic functions applied to them, most other BigInts I have seen in other languages have their own BigInt arithmetic functions which make life a mind bending hassle  $x=$bigint1.add($x,$y); for example.

So..... my point?

Numbers and strings are interchangeable (as written in many a Perl book) so you can just assign a numeric variable in the place of a string:

use Math::BigInt; $std1 = 67*34; $bigint1 = Math::BigInt->new($std1); print "std: $std1\nbigint: $bigint1\n";
Just wanted to contribute to the topic as we veered off it :)


Comment on Re: (tye) BigInt usage
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (14)
As of 2014-08-27 17:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (247 votes), past polls