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.

*integer-format*

*integer-format*

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

SYNTAX

*integer-format*

DESCRIPTION

*INTEGER-FORMAT* is a system variable that allows a user to specify how integer numbers are to be printed by XLISP. The value of *INTEGER-FORMAT* should be set to one of the string expressions "%ld", "%lo" or "%lx". The character after the percent character is the alphabetic 'ell' character. These format strings are similar to C-language floating point specifications.

format          description
---------------------------------------------------
"%ld"           decimal
"%lu"           unsigned decimal
"%lo"           unsigned octal
"%lx"           unsigned hexadecimal

The default value for *INTEGER-FORMAT* is the string "%ld".

EXAMPLES

*integer-format*                        ; returns "%ld"
                                        ;
(setq *integer-format* "%ld")           ; signed decimal
(print 1)                               ; prints 1
(print 1234)                            ; prints 1234
(print -1)                              ; prints -1
(print -1234)                           ; prints -1234
                                        ;
(setq *integer-format* "%lo")           ; octal notation
(print 1)                               ; prints 1
(print 1234)                            ; prints 2322
(print -1)                              ; prints 37777777777
(print -1234)                           ; prints 37777775456
                                        ;
(setq *integer-format* "%lx")           ; hexadecimal notation
(print 1)                               ; prints 1
(print -1)                              ; prints ffffffff
(print 1234)                            ; prints 4d2
(print -1234)                           ; prints fffffb2e
                                        ;
(setq *integer-format* "%u")            ; unsigned decimal
(print 1)                               ; prints 1
(print 1234)                            ; prints 1234
(print -1)                              ; prints 4294967295
(print -1234)                           ; prints 4294966062
                                        ;
(setq *integer-format* "hi")            ; a bad notation
(print 1)                               ; prints hi
(print 9999)                            ; prints hi
                                        ;
(setq *integer-format* "%ld")           ; reset to original "%ld"

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.