Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Big Numbers

by Abigail-II (Bishop)
on Jul 22, 2002 at 14:24 UTC ( [id://184063]=note: print w/replies, xml ) Need Help??


in reply to Re: Big Numbers
in thread Big Numbers

Repeated division? How come? Here's a simple routine that translates hex numbers into decimal ones. Replace the my $answer = 0; with my $answer = Math::BigInt -> new (0); to extend it bigger numbers.
my $c = 0; my %X = map {$_ => $c ++} 0 .. 9, 'A' .. 'F'; sub hex2dec { local $_ = shift; my $answer = 0; ($answer <<= 4) += $X {substr $_ => 0, 1, ""} while length; $answer; }
Abigail

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-03-28 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found