Version 0 of Big integer routines

Updated 2003-01-02 09:15:53

Richard Suchenwirth - Using plain strings of digits, unsigned integers of arbitrarily large size can be represented in Tcl. In KISS I showed my versions of addition and multiplication; here now comes division (a big int divided by a regular int, may be 64 bits wide). The aim of such studies is of course factorisation of large integers...

 proc bigint'div {dividend divisor} {#
    set carry ""
    set res ""
    foreach digit [split $dividend ""] {
       set carry [scan [append carry  $digit] %d]
       append res [expr {$carry / $divisor}]
       set carry  [expr {$carry % $divisor}]
    }
    list [string trimleft $res 0] $carry
 }