format
Sets the format for displaying numbers.
Syntax
format()
format('long')
format('short')
format('long', 'e')
format('long', 'E')
format('short', 'e')
format('short', 'E')
format(x, y)
Inputs
- x
- The maximum value is 18. If x is more than 18, a default value of 18 is applied for formatting.
- y
- The maximum value is 18. If y is more than 18, a default value of 18 is applied for formatting.
Examples
Displays in long and short format:
x=[5.123876+4i,2-9i;3+3.5567456i, 2.31478765+9.765756774i];
format('long')
x
format('short')
x
x = [Matrix] 2 x 2
5.12387600 + 4.00000000i 2.00000000 - 9.00000000i
3.00000000 + 3.55674560i 2.31478765 + 9.76575677i
x = [Matrix] 2 x 2
5.12388 + 4.00000i 2.00000 - 9.00000i
3.00000 + 3.55675i 2.31479 + 9.76576i
Displays in long and short scientific format:
x=[5.123876+4i,2-9i;3+3.5567456i, 2.31478765+9.765756774i];
format('long', 'e')
x
format('short', 'E')
x
x = [Matrix] 2 x 2
5.12387600e+00 + 4.00000000e+00i 2.00000000e+00 - 9.00000000e+00i
3.00000000e+00 + 3.55674560e+00i 2.31478765e+00 + 9.76575677e+00i
x = [Matrix] 2 x 2
5.12388E+00 + 4.00000E+00i 2.00000E+00 - 9.00000E+00i
3.00000E+00 + 3.55675E+00i 2.31479E+00 + 9.76576E+00i
Displays in custom format:
x=12345.678901;
format(5,2)
x
x = 12345.68
Comments
By default, 9 significant digits are displayed. Format with no input arguments will reset to this default display. Format 'long' will display 16 significant digits, with a precision of 8. Format 'short' will display 6 significant digits, with a precision of 5. Format 'long', 'e'/'E' will display in long, scientific lower or uppercase notation respectively. Format 'short', 'e'/'E' will display in short, lower or uppercase scientific notation respectively. Optional arguments, x and y can also specify the number of significant digits and the precision, where x and y are finite, positive integers.