<?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>format -- format a string or a real number</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_lines.html">next</a> | <a href="_concatenate.html">previous</a> | <a href="_lines.html">forward</a> | <a href="_concatenate.html">backward</a> | <a href="_strings_spand_spnets.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="_strings_spand_spnets.html" title="">strings and nets</a> > <a href="_format.html" title="format a string or a real number">format</a></div> <hr/> <div><h1>format -- format a string or a real number</h1> <div class="single"><h2>Description</h2> <div><div><h2>Synopsis</h2> <ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>format(s)</tt></div> </dd></dl> </div> </li> <li>Inputs:<ul><li><span><tt>s</tt></span></li> </ul> </li> <li>Outputs:<ul><li><span>a string obtained from <tt>s</tt> by inserting escape sequences, thereby preparing it for printing in a form suitable for reading in again</span></li> </ul> </li> </ul> <table class="examples"><tr><td><pre>i1 : s = "a\"b\"c" o1 = a"b"c</pre> </td></tr> <tr><td><pre>i2 : t = format s o2 = "a\"b\"c"</pre> </td></tr> <tr><td><pre>i3 : u = value t o3 = a"b"c</pre> </td></tr> <tr><td><pre>i4 : u == s o4 = true</pre> </td></tr> </table> </div> <div><h2>Synopsis</h2> <ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>format(s,k,l,t,e,x)</tt></div> </dd></dl> </div> </li> <li>Inputs:<ul><li><span><tt>s</tt>, <span>an <a href="___Z__Z.html">integer</a></span>, the maximum number of significant decimal digits (default: <a href="_printing__Precision.html" title="current precision for printing numbers">printingPrecision</a>). The special value <tt>0</tt> imposes no limit.</span></li> <li><span><tt>k</tt>, <span>an <a href="___Z__Z.html">integer</a></span>, how far to the right of the decimal point to go, at most (default: <a href="_printing__Accuracy.html" title="current accuracy for printing numbers">printingAccuracy</a>). The special value <tt>-1</tt> imposes no limit.</span></li> <li><span><tt>l</tt>, <span>an <a href="___Z__Z.html">integer</a></span>, maximum number of leading zeroes (default: <a href="_printing__Lead__Limit.html" title="maximum number of leading zeroes to use when printing real numbers">printingLeadLimit</a>)</span></li> <li><span><tt>t</tt>, <span>an <a href="___Z__Z.html">integer</a></span>, maximum number of trailing zeroes (default: <a href="_printing__Trail__Limit.html" title="maximum number of additional trailing digits to use when printing real numbers">printingTrailLimit</a>)</span></li> <li><span><tt>e</tt>, <span>a <a href="___String.html">string</a></span>, the separator between the mantissa and the exponent (default: <a href="_printing__Separator.html" title="string used to separate mantissa from exponent when printing real numbers">printingSeparator</a>)</span></li> <li><span><tt>x</tt>, <span>a <a href="___R__R.html">real number</a></span>, the number to be converted to a string</span></li> </ul> </li> <li>Outputs:<ul><li><span><span>a <a href="___String.html">string</a></span>, the decimal representation of the number <tt>x</tt>, prepared according to the parameters above</span></li> </ul> </li> </ul> <table class="examples"><tr><td><pre>i5 : format(10,1/3000.) o5 = .0003333333333</pre> </td></tr> <tr><td><pre>i6 : format(10,6,1/3000.) o6 = .000333</pre> </td></tr> <tr><td><pre>i7 : format(10,6,2,1/3000.) o7 = 3.33e-4</pre> </td></tr> <tr><td><pre>i8 : format(10,300000.) o8 = 300000</pre> </td></tr> <tr><td><pre>i9 : format(10,-1,10,5,300000.) o9 = 300000</pre> </td></tr> <tr><td><pre>i10 : format(10,-1,10,4,300000.) o10 = 3e5</pre> </td></tr> <tr><td><pre>i11 : format(10,-1,10,4,"E",300000.) o11 = 3E5</pre> </td></tr> </table> </div> </div> </div> <div class="single"><h2>See also</h2> <ul><li><span><a href="_to__External__String.html" title="convert to a readable string">toExternalString</a> -- convert to a readable string</span></li> </ul> </div> </div> </body> </html>