next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc > rings > basic rings of numbers

basic rings of numbers

The following rings are initially present in every session with Macaulay2. 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.

i1 : 1234

o1 = 1234
i2 : 123/4

     123
o2 = ---
      4

o2 : QQ
i3 : 123.4

o3 = 123.4

o3 : RR (of precision 53)
i4 : 1.234e-20

o4 = 1.234e-20

o4 : RR (of precision 53)
i5 : 123+4*ii

o5 = 123+4*ii

o5 : CC (of precision 53)
The usual arithmetic operations are available.
i6 : 4/5 + 2/3

     22
o6 = --
     15

o6 : QQ
i7 : 10^20

o7 = 100000000000000000000
i8 : 3*5*7

o8 = 105
i9 : 3.1^2.1

o9 = 10.7611716060997

o9 : RR (of precision 53)
i10 : sqrt 3.

o10 = 1.73205080756888

o10 : RR (of precision 53)
An additional pair of division operations that produce integer quotients and remainders is available.
i11 : 1234//100

o11 = 12
i12 : 1234%100

o12 = 34
Numbers can be promoted to larger rings as follows, see RingElement _ Ring.
i13 : 1_QQ

o13 = 1

o13 : QQ
i14 : (2/3)_CC

o14 = .666666666666667

o14 : CC (of precision 53)
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.
i15 : 1p300

o15 = 1

o15 : RR (of precision 300)
i16 : 1p300e-30

o16 = 1e-30

o16 : RR (of precision 300)
Numbers can be lifted to smaller rings as follows, see lift.
i17 : x = 2/3*ii/ii

o17 = .666666666666667

o17 : CC (of precision 53)
i18 : lift(x,RR)

o18 = .666666666666667

o18 : RR (of precision 53)
i19 : lift(x,QQ)

      2
o19 = -
      3

o19 : QQ