The following rings are initially present in every session with Macaulay2.
- ZZ -- the class of all integers
- QQ -- the class of all rational numbers
- RR -- the class of all real numbers
- CC -- the class of all complex numbers
The names of some of these rings are double letters so the corresponding symbols with single letters are preserved for use as variables.
Numbers in these rings are constructed as follows.
1234 |
123/4 |
123.4 |
1.234e-20 |
123+4*ii |
The usual arithmetic operations are available.
4/5 + 2/3 |
10^20 |
3*5*7 |
3.1^2.1 |
sqrt 3. |
An additional pair of division operations that produce integer quotients and remainders is available.
Numbers can be promoted to larger rings as follows, see
RingElement _ Ring.
One way to enter real and complex numbers with more precision is to insert the desired number of bits of precision after the letter p at the end of the number, but before the possible e that indicates the exponent of 10.
Numbers can be lifted to smaller rings as follows, see
lift.
x = 2/3*ii/ii |
lift(x,RR) |
lift(x,QQ) |