Integers and rational numbers
In Macaulay2, integers and rational numbers have any number of digits (up to memory limits at least).
i1 : 21672378126371263123123
o1 = 21672378126371263123123
|
i2 : 3748568762746238746278/5876584978947
1249522920915412915426
o2 = ----------------------
1958861659649
o2 : QQ
|
Integers are elements of the ring
ZZ of integers, and rational numbers are elements of the ring
QQ of rational numbers.
One point to notice is that there are two kinds of division,
/ and
//. The first returns a rational number (element of
QQ), while the second does division in
ZZ.
i3 : 6/3
o3 = 2
o3 : QQ
|
i4 : 7//3
o4 = 2
|
Real and complex numbers
Real and complex numbers are approximate numbers, implemented using the machine's double precision arithmetic.
i5 : 1.372489274987
o5 = 1.37249
o5 : RR
|
i6 : 1.3454353 * 10^20
o6 = 1.34544*10^20
o6 : RR
|
i7 : sqrt 4.5
o7 = 2.12132
o7 : RR
|
i8 : 1/(1+ii)
o8 = 0.5 - 0.5ii
o8 : CC
|
There are also arbitrary precision real and complex numbers. See
RRR or
CCC for more details.