2 single: bignumber; Introduction
8 In this chapter we will learn about using the Big Number library in the Ring programming language.
10 Developers : Bert Mariani, Gal Zsolt (~ CalmoSoft ~)
13 pair: bignumber; Loading the library
18 Before using the next function load the bignumber.ring library
23 # Use Big Number library functions
26 pair: bignumber; Examples
31 Using the BigNumber library we can do arithmetic operations on huge numbers.
39 num1 = "62345678901234567891678345123456789" ### Big
40 num2 = "1237894567890123419871236545" ### Small
41 num3 = "64" ### Divide Small
46 a1 = new BigNumber(num1) a1.Print()
47 a2 = new BigNumber(num2) a2.Print()
48 a3 = a1 + a2 a3.Print() ? nl
50 ? "Substract big numbers:"
51 a1 = new BigNumber(num1) a1.Print()
52 a2 = new BigNumber(num2) a2.Print()
53 a3 = a1 - a2 a3.Print() ? nl
55 ? "Multiply big numbers:"
56 a1 = new BigNumber(num1) a1.print()
57 a2 = new BigNumber(num2) a2.print()
58 a3 = a1 * a2 a3.print() ? nl
60 ? "Divide big numbers:"
61 a1 = new BigNumber(num1) a1.print()
62 a2 = new BigNumber(num2) a2.print()
63 a3 = a1 / a2 a3.print() ? nl
65 ? "Divide big numbers: by very small number"
66 a1 = new BigNumber(num1) a1.print()
67 a2 = new BigNumber(num3) a2.print()
68 a3 = a1 / a2 a3.print() ? nl
70 ? "Power of big number:"
71 a1 = new BigNumber(num1) a1.print()
72 a2 = new BigNumber(num5) a2.print()
73 a3 = a1 ^ a2 a3.print() ? nl
80 62345678901234567891678345123456789
81 1237894567890123419871236545
82 62345680139129135781801764994693334
85 Substract big numbers:
86 62345678901234567891678345123456789
87 1237894567890123419871236545
88 52345687663340000001554925252220244
92 62345678901234567891678345123456789
93 1237894567890123419871236545
94 77177377243260150103462178714197454736432472780119682305154005
98 62345678901234567891678345123456789
99 1237894567890123419871236545
103 Divide big numbers: by very small number
104 62345678901234567891678345123456789
106 974151232831790123307474142554012
110 62345678901234567891678345123456789
112 242336636261471172092347146031727004 (Output continue in next line)
113 371698195628343934238988256152289508 (Output continue in next line)
114 493964611043228971692389860897069
118 pair: bignumber; BigNumber Functions
123 The library contains the next functions
128 FuncSubtract(num1,num2)
129 FuncCompare(num1,num2)
130 FuncDivide(num1,num2)
131 FuncMultiply(num1,num2)
133 FuncBinaryToDecimal(num1)
134 FuncDecimalToBinary(num1)
135 printBinaryDigits(binList)
136 printDecimalDigits(decList)
139 pair: bignumber; BigNumber Class
144 The library contains the next class
150 func operator cOperator, Para
155 pair: bignumber; Library Source Code
160 You can see the library source code in : ring/ringlibs/bignumber folder
162 Source Code : https://github.com/ring-lang/ring/blob/master/ringlibs/bignumber/bignumber.ring