*float-format* is a system variable that allows a user to specify how floating point numbers are to be printed by XLISP. The value of *float-format* should be set to one of the string expressions "%e", "%f" or "%g". These format strings are similar to C-language floating point specifications:
"%e" |
|
exponential. The number is converted to decimal notation
of the form:
[-]m.nnnnnnE[+-]xxThere is one leading digit. There are 6 digits after the decimal point. |
"%f" |
|
decimal. The number is converted to decimal notation of
the form:
[-]mmmmmm.nnnnnnThere are as many digits before the decimal point as necessary. There are 6 digits after the decimal point. |
"%g" |
|
shortest. The number is converted to either the form of "%e" or "%f", whichever produces the shortest output string. Non-significant zeroes are not printed. |
The default value for *float-format* is the string "%g".
There are several additional flags and options available:
|
+ |
- |
|
|
space |
- |
|
|
# |
- |
|
|
.n |
- |
The flags and options must be written between the "%" and the formatting letter, as shown in the examples below.
(setq *float-format* "%e") ; exponential notation (print 1.0) => 1.000000e+00 (print -9e99) => -9.000000e+99 (setq *float-format* "%f") ; decimal notation (print 1.0) => 1.000000 (print 1.0e4) => 10000.000000 (print -999.99e-99) => -0.000000 (setq *float-format* "%g") ; shortest notation (print 1.0) => 1 (print 1.0e7) => 1e+07 (print -999.999e99) => -9.99999e+101 (setq *float-format* "%+g") ; always print the sign (print 1.1) => +1.1 (print -1.1) => -1.1 (setq *float-format* "% g") ; print a space instead of the + sign (print 1.1) => 1.1 (print -1.1) => -1.1 (setq *float-format* "%#.10g") ; ten digits after the dot (print 1.0) => 1.000000000 (print 1.0e7) => 10000000.00 (print -999.9999999e99) => -9.999999999e+101 (setq *float-format* "%+#.10g") ; ten digits after the dot plus sign (print 1.2345) => +1.234500000 (print -1.2345) => -1.234500000 (setq *float-format* "%%") ; bad format (print 1.0) => %% (setq *float-format* "%g") ; reset to shortest notation
Note: The string in the