Understanding the use of BigInt

I am trying to figure out how to use it correctly BigInt. It seems to me what needs to be used BigIntwhen Int64or Int128not enough, and apparently BigIntuses arbitrary arithmetic of precision (which I don't know about).

Let's say I want to calculate the factorial of some large number, for example. 30. I do not know how many bits are required for storage factorial(30), but both

test = Int128
test = factorial(30)

and

test = BigInt
test = factorial(30)

creates -8764578968847253504, which is obviously wrong.

According to the Julia lang documentation, it seems that for this type (BigInt) the usual mathematical operators are defined, and the results are advanced to BigInt. Therefore, I do not see what I am doing wrong, I obviously understood something wrong. Hoping some of you can explain to me :)

PS: 64- Windows 7, .

+4
2

factorial , ,

test = factorial(BigInt(30))  

, BigInt .

test = BigInt(factorial(30))

, Int BigInt.

test = BigInt(factorial(BigInt(30)))

, BigInt , BigInt.

,

test = BigInt
test = factorial(30)

.

Julia lang, , (BigInt) , BigInt.

, , , " BigInt", . BigInt , factorial Int 30. test, , BigInt. , "" . Julia Ints BigInts - BigInt. ( ) .

BigInt - (, ). BigInt , . BigInt - , . Int ( , Int64 ), - .

+7

, , http://julia.readthedocs.org/en/latest/manual/integers-and-floating-point-numbers/#man-arbitrary-precision-arithmetic, factorial(BigInt(40)), , , .

factorial(BigInt(30)), , .

, :

, BigInt/BigFloat .

, 3 , , :

test = factorial(BigInt(30))
test = BigInt(factorial(30))
test = BigInt(factorial(BigInt(30)))
0

All Articles