Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 4828

Macaulay2-1.3.1-8.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8" ?>  <!-- for emacs: -*- coding: utf-8 -*- -->
<!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"	 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>numeric types</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_strings_spand_spnets.html">next</a> | <a href="_numbered_spvariables.html">previous</a> | <a href="_strings_spand_spnets.html">forward</a> | <a href="_variables.html">backward</a> | <a href="___The_sp__Macaulay2_splanguage.html">up</a> | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div>

    </td>
  </tr>
</table>
<div><a href="index.html" title="">Macaulay2Doc</a> > <a href="___The_sp__Macaulay2_splanguage.html" title="">The Macaulay2 language</a> > <a href="_numeric_sptypes.html" title="">numeric types</a></div>
<hr/>
<div><h1>numeric types</h1>
<div><h3>Integers and rational numbers</h3>
In Macaulay2, integers and rational numbers have any number of digits (up to memory limits at least).<table class="examples"><tr><td><pre>i1 : 21672378126371263123123

o1 = 21672378126371263123123</pre>
</td></tr>
<tr><td><pre>i2 : 3748568762746238746278/5876584978947

     1249522920915412915426
o2 = ----------------------
          1958861659649

o2 : QQ</pre>
</td></tr>
</table>
Integers are elements of the ring <a href="___Z__Z.html" title="the class of all integers">ZZ</a> of integers, and rational numbers are elements of the ring <a href="___Q__Q.html" title="the class of all rational numbers">QQ</a> of rational numbers.<p/>
One point to notice is that there are two kinds of division, <a href="__sl.html" title="a binary operator, usually used for division">/</a> and <a href="__sl_sl.html" title="a binary operator, usually used for quotient">//</a>.  The first returns a rational number (element of <a href="___Q__Q.html" title="the class of all rational numbers">QQ</a>), while the second does division in <a href="___Z__Z.html" title="the class of all integers">ZZ</a>.<table class="examples"><tr><td><pre>i3 : 6/3

o3 = 2

o3 : QQ</pre>
</td></tr>
<tr><td><pre>i4 : 7//3

o4 = 2</pre>
</td></tr>
</table>
<h3>Real and complex numbers</h3>
Real and complex numbers are approximate numbers, implemented using the <a href="___M__P__F__R.html" title="">MPFR</a> library.<table class="examples"><tr><td><pre>i5 : 1.372489274987

o5 = 1.372489274987

o5 : RR (of precision 53)</pre>
</td></tr>
<tr><td><pre>i6 : 1.3454353 * 10^20

o6 = 1.3454353e20

o6 : RR (of precision 53)</pre>
</td></tr>
<tr><td><pre>i7 : sqrt 4.5

o7 = 2.12132034355964

o7 : RR (of precision 53)</pre>
</td></tr>
<tr><td><pre>i8 : toRR_200 4.5

o8 = 4.5

o8 : RR (of precision 200)</pre>
</td></tr>
<tr><td><pre>i9 : sqrt oo

o9 = 2.12132034355964257320253308631454711785450781306542210976502

o9 : RR (of precision 200)</pre>
</td></tr>
</table>
<table class="examples"><tr><td><pre>i10 : 1/(1+ii)

o10 = .5-.5*ii

o10 : CC (of precision 53)</pre>
</td></tr>
</table>
</div>
<div class="single"><h2>See also</h2>
<ul><li><span><a href="___Number.html" title="the class of all numbers">Number</a> -- the class of all numbers</span></li>
<li><span><a href="___Z__Z.html" title="the class of all integers">ZZ</a> -- the class of all integers</span></li>
<li><span><a href="___Q__Q.html" title="the class of all rational numbers">QQ</a> -- the class of all rational numbers</span></li>
<li><span><a href="___R__R.html" title="the class of all real numbers">RR</a> -- the class of all real numbers</span></li>
<li><span><a href="___C__C.html" title="the class of all complex numbers">CC</a> -- the class of all complex numbers</span></li>
<li><span><a href="_to__R__R.html" title="convert to high-precision real number">toRR</a> -- convert to high-precision real number</span></li>
<li><span><a href="_to__C__C.html" title="convert to high-precision complex number">toCC</a> -- convert to high-precision complex number</span></li>
</ul>
</div>
</div>
</body>
</html>