Add two big rationals .
Prototype
int BigRat.add( brat1 , bnum2 , bnum3 )
Parameters
brat1 and bnum2
Numbers to be added.
brat3
Returns the sum of brat1 and bnum2.
Remarks
brat1 , bnum2 and bnum3 must be created before function call
Example
require( "BigRat.lua" )
a = BigRat.new( "639" )
b = BigRat.new( "563" )
result = BigRat.new( )
BigRat.add( a , b , result )
print( a .. " + " .. b .. " = " .. result )
a = BigRat.new( "-543" )
b = BigRat.new( "1256" )
BigRat.add( a , b , result )
print( a .. " + " .. b .. " = " .. result )
--Try to add non valid parameters
ret = BigRat.add( a , d , result )
print( ret ) ;
Output
639 + 563 = 1202
-543 + 1256 = 713
0