Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

*float-format*

*float-format*

type: system variable 
location: built-in
source file: xlprin.c
Common LISP compatible: no
supported on: all machines

SYNTAX

*float-format*

DESCRIPTION

*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.

format  name            description
----------------------------------------------------------------
%e      exponential     The  number  is  converted   to  decimal
                        notation of the form [-]m.nnnnnnE[+-]xx.
                        There 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.nnnnnn .
                        There  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".

EXAMPLES

(setq *float-format* "%e")              ; exponential notation
(print 1.0)                             ; prints 1.000000e+00
(print -9e99)                           ; prints -9.000000e+99
(setq *float-format* "%f")              ; decimal notation
(print 1.0)                             ; prints 1.000000
(print 1.0e4)                           ; prints 10000.000000
(print -999.99e-99)                     ; prints -0.000000
(setq *float-format* "%g")              ; shortest notation
(print 1.0)                             ; prints 1
(print 1.0e6)                           ; prints 1000000
(print 1.0e7)                           ; prints 1e+07
(print -999.999e99)                     ; prints -9.99999e+101
(setq *float-format* "SOMETHING")       ; bad notation
(print 1.0)                             ; prints SOMETHING
(setq *float-format* "%g")              ; reset to shortest notation

NOTE: There can be other characters put in the string, but in general, this will not produce particularly desirable behaviour. There is no error checking performed on the format string.


Go to the first, previous, next, last section, table of contents.