manpagez: man pages & more
info cln
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 Internal and printed representation

All computations deal with the internal representations of the numbers.

Every number has an external representation as a sequence of ASCII characters. Several external representations may denote the same number, for example, "20.0" and "20.000".

Converting an internal to an external representation is called “printing”, converting an external to an internal representation is called “reading”. In CLN, it is always true that conversion of an internal to an external representation and then back to an internal representation will yield the same internal representation. Symbolically: read(print(x)) == x. This is called “print-read consistency”.

Different types of numbers have different external representations (case is insignificant):

Integers

External representation: sign{digit}+. The reader also accepts the Common Lisp syntaxes sign{digit}+. with a trailing dot for decimal integers and the #nR, #b, #o, #x prefixes.

Rational numbers

External representation: sign{digit}+/{digit}+. The #nR, #b, #o, #x prefixes are allowed here as well.

Floating-point numbers

External representation: sign{digit}*exponent or sign{digit}*.{digit}*exponent or sign{digit}*.{digit}+. A precision specifier of the form _prec may be appended. There must be at least one digit in the non-exponent part. The exponent has the syntax expmarker expsign {digit}+. The exponent marker is

  • s’ for short-floats,
  • f’ for single-floats,
  • d’ for double-floats,
  • L’ for long-floats,

or ‘e’, which denotes a default float format. The precision specifying suffix has the syntax _prec where prec denotes the number of valid mantissa digits (in decimal, excluding leading zeroes), cf. also function ‘float_format’.

Complex numbers

External representation:

  • In algebraic notation: realpart+imagparti. Of course, if imagpart is negative, its printed representation begins with a ‘-’, and the ‘+’ between realpart and imagpart may be omitted. Note that this notation cannot be used when the imagpart is rational and the rational number’s base is >18, because the ‘i’ is then read as a digit.
  • In Common Lisp notation: #C(realpart imagpart).

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on August 27, 2013 using texi2html 5.0.

© manpagez.com 2000-2017
Individual documents may contain additional copyright information.