Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Division of big integers

by tybalt89 (Monsignor)
on Dec 31, 2024 at 22:28 UTC ( [id://11163469]=note: print w/replies, xml ) Need Help??


in reply to Re: Division of big integers
in thread Division of big integers

And here's a shorter 'bigdivide'.

sub bigdivide { my ($t, $d) = map s/^0+(?=.)//r, @_; my $q = 0; $d .= 0 x (my $zeros = length($t) - length $d); for ( 0 .. $zeros ) { $q .= 0; while( defined( my $try = bigsubtract( $t, $d ) ) ) { $t = $try; $q++; } chop $d; } return ($q || 0) =~ s/^0+(?=.)//r; }
UPDATE: Should be 'defined' in the while :(

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2025-11-09 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (65 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.