BigNum.div

Divide two big numbers. This function uses Basecase division algorithm, as described in GNU MP 4.1

Prototype
   int BigNum.div( bnum1 , bnum2 , bnum3 , bnum4 )

Parameters
   bnum1 and bnum2
      Numbers to be divided.
   bnum3
      Returns the integer division of bnum1 and bnum2.
   bnum4
      Returns the rest of the division.

Remarks
   bnum1, bnum2, bnum3 , bnum4 must be created before function call
   If bnum2 == 0 then function reports an error.

Example
   
require( "BigNum.lua" )

a = BigNum.new( "639" )
b = BigNum.new( "11" )
quo = BigNum.new( )
rest = BigNum.new( )
BigNum.div( a , b , quo , rest )
print( a .. " / " .. b .. " = " .. quo )
print( a .. " mod  " .. b .. " = " .. rest )

a = BigNum.new( "-543" )
b = BigNum.new( "-1256" )
BigNum.div( a , b , quo , rest )
print( a .. " / " .. b .. " = " .. quo )
print( a .. " mod " .. b .. " = " .. rest )

--Try to add non valid parameters
ret = BigNum.div( a , d , quo , rest )
print( ret ) ;
   
Output 639 / 11 = 58 639 mod 11 = 1 -543 / -1256 = 0 -543 mod -1256 = -543 0