www.delorie.com/gnu/docs/guile/guile_175.html   search  
 
Buy GNU books!


Guile Reference Manual

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

21.2.6 Read Syntax for Numerical Data

The read syntax for integers is a string of digits, optionally preceded by a minus or plus character, a code indicating the base in which the integer is encoded, and a code indicating whether the number is exact or inexact. The supported base codes are:

If the base code is omitted, the integer is assumed to be decimal. The following examples show how these base codes are used.

 
-13
=>
-13

#d-13
=>
-13

#x-13
=>
-19

#b+1101
=>
13

#o377
=>
255

The codes for indicating exactness (which can, incidentally, be applied to all numerical values) are:

If the exactness indicator is omitted, the integer is assumed to be exact, since Guile's internal representation for integers is always exact. Real numbers have limited precision similar to the precision of the double type in C. A consequence of the limited precision is that all real numbers in Guile are also rational, since any number R with a limited number of decimal places, say N, can be made into an integer by multiplying by 10^N.


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003