此为 Mathematica 4 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.1)

NumberForm

Usage

NumberForm[expr, n]n为精确度输出expr中的近似实数.


Notes

NumberForm[expr,  n, f ]输出具有n个数位的近似实数,其中小数点后占 f 位.
NumberForm 既适用于整数,也适用于近似实数.
• 可以使用下列可选项:
"\!\(\*StyleBox[\"\\\"DigitBlock\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"Infinity\\\"\", \"MR\"]\) "空格之间的数位
"\!\(\*StyleBox[\"\\\"ExponentFunction\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"Automatic\\\"\", \"MR\"]\) """要应用到指数上的函数
"\!\(\*StyleBox[\"\\\"NumberFormat\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"Automatic\\\"\", \"MR\"]\) "用来组合尾数,基底,指数的函数
"\!\(\*StyleBox[\"\\\"NumberPadding\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"{\\\\\\\"\\\\\\\",\\\"\", \"MR\"]\) \!\(\*StyleBox[\"\\\"\\\\\\\"\\\\\\\"}\\\"\", \"MR\"]\) "用作左右填充字符的字符串
"\!\(\*StyleBox[\"\\\"NumberPoint\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"\\\\\\\".\\\\\\\"\\\"\", \"MR\"]\) "小数点字符串
"\!\(\*StyleBox[\"\\\"NumberSeparator\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"\\\\\\\",\\\\\\\"\\\"\", \"MR\"]\) ""在数据块之间的空格处插入的字符串"
"\!\(\*StyleBox[\"\\\"NumberSigns\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"{\\\\\\\"-\\\\\\\",\\\"\", \"MR\"]\) \!\(\*StyleBox[\"\\\"\\\\\\\"+\\\\\\\"}\\\"\", \"MR\"]\) "用来标识负数和正书的字符串
"\!\(\*StyleBox[\"\\\"SignPadding\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"False\\\"\", \"MR\"]\) "是否在标记后插入填充字符
• 除ExponentFunction外,所有可选项都同时适用于整数和近似实数.
• 可以把NumberFormBaseForm混合使用.
NumberForm相当于一个"包装",它只影响输出,不影响计算.
• 参见 Mathematica全书: 2.8.7节.
Further Examples

This breaks digits into blocks of length 3.

In[1]:=  

Out[1]//NumberForm=

You can specify any string to use as a separator between blocks of digits.

In[2]:=  

Out[2]//NumberForm=

This gives an explicit plus sign for positive numbers, and uses | in place of a decimal point.

In[3]:=  

Out[3]//NumberForm=