XLISP *integer-format*

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# *integer-format*

Type: | - | system variable
Source: | - | xlprin.c

## 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 lower-case 'L' character]. These format strings are similar to C-language floating point specifications:

`"%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.

See the *integer-format* system variable in the XLISP 2.0 manual.

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference