|
Contents | Previous | Next | Subchapters |
| Syntax |
format real formformform
|
| See Also | format and format int |
If you enter
format real "f5"
x = [1.2, 2.4, 3.6]
x
O-Matrix will respond
[ 1 , 2 , 4 ]
Note that the values are rounded to the nearest integer.
If you continue by entering
format real "f5.2"
x
O-Matrix will respond
[ 1.20 , 2.40 , 3.60 ]
The format statement also affects the values output by the
write
function.
If you enter
x = double(x)
format double "f5.2"
write("screen", x)
O-Matrix will respond
1.20 2.40 3.60
In addition, the format statement affects the values
returned by the ntoa
function.
If you enter
x = complex(x)'
format complex "f5.2"
ntoa(x)
O-Matrix will respond
( 1.20, 0.00)
( 2.40, 0.00)
( 3.60, 0.00)
If you enter
format real "e12.3"
x = [1.1, 10.1, 100.01]
x
O-Matrix will respond
[ 1.100e+000 , 1.010e+001 , 1.000e+002 ]
The "e",
the sign of the exponent,
and the exponent itself combine to occupy five columns of output.
If you enter
x = [1.1, 10.1, 100.01]
format double "g12.2"
double(x)
O-Matrix will respond
[ 1.1 , 10 , 1e+002 ]
x = 12345r0
format complex "f5.2"
x
O-Matrix will respond
(*****,*****)
On the other hand, if you just specify the type of formatting,
"f", "e" or "g",
O-Matrix will adjust the number of columns and decimal places
to fit the value being printed.
If you continue the example above by entering
format complex "g"
x
O-Matrix will respond
(12345,0)
("g" is the default setting for the O-Matrix floating point output values.)
format real ""
format double ""
format complex ""
reset the floating point formats to their default values.