/[guile]/guile/guile-core/doc/ref/scheme-data.texi
ViewVC logotype

Diff of /guile/guile-core/doc/ref/scheme-data.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by ossau, Mon Apr 1 14:44:02 2002 UTC revision 1.18 by mvo, Thu May 9 19:35:42 2002 UTC
# Line 259  representation where the required number Line 259  representation where the required number
259  form.  Conversion between these two representations is automatic and  form.  Conversion between these two representations is automatic and
260  completely invisible to the Scheme level programmer.  completely invisible to the Scheme level programmer.
261    
262    The infinities @code{+inf.0} and @code{-inf.0} are considered to be
263    inexact integers.  They are explained in detail in the next section,
264    together with reals and rationals.
265    
266  @c REFFIXME Maybe point here to discussion of handling immediates/bignums  @c REFFIXME Maybe point here to discussion of handling immediates/bignums
267  @c on the C level, where the conversion is not so automatic - NJ  @c on the C level, where the conversion is not so automatic - NJ
268    
# Line 274  Return @code{#t} if @var{x} is an intege Line 278  Return @code{#t} if @var{x} is an intege
278  (integer? -3.4)  (integer? -3.4)
279  @result{}  @result{}
280  #f  #f
281    
282    (integer? +inf.0)
283    @result{}
284    #t
285  @end lisp  @end lisp
286  @end deffn  @end deffn
287    
# Line 326  rational numbers and real irrational num Line 334  rational numbers and real irrational num
334  and in such a way that the new kinds of number integrate seamlessly  and in such a way that the new kinds of number integrate seamlessly
335  with those that are already implemented.  with those that are already implemented.
336    
337    Dividing by an exact zero leads to a error message, as one might
338    expect.  However, dividing by an inexact zero does not produce an
339    error.  Instead, the result of the division is either plus or minus
340    infinity, depending on the sign of the divided number.
341    
342    The infinities are written @samp{+inf.0} and @samp{-inf.0},
343    respectibly.  This syntax is also recognized by @code{read} as an
344    extension to the usual Scheme syntax.
345    
346    Dividing zero by zero yields something that is not a number at all:
347    @samp{+nan.0}.  This is the special 'not a number' value.
348    
349    On platforms that follow IEEE 754 for their floating point arithmetic,
350    the @samp{+inf.0}, @samp{-inf.0}, and @samp{+nan.0} values are
351    implemented using the corresponding IEEE 754 values.  They behave in
352    arithmetic operations like IEEE 754 describes it, i.e., @code{(=
353    +nan.0 +nan.0) @result{#f}}.
354    
355    The infinities are inexact integers and are considered to be both even
356    and odd.  While @samp{+nan.0} is not @code{=} to itself, it is
357    @code{eqv?} to itself.
358    
359    To test for the special values, use the functions @code{inf?} and
360    @code{nan?}.
361    
362  @deffn {Scheme Procedure} real? obj  @deffn {Scheme Procedure} real? obj
363  @deffnx {C Function} scm_real_p (obj)  @deffnx {C Function} scm_real_p (obj)
364  Return @code{#t} if @var{obj} is a real number, else @code{#f}.  Return @code{#t} if @var{obj} is a real number, else @code{#f}.
# Line 344  will also satisfy this predicate, becaus Line 377  will also satisfy this predicate, becaus
377  precision.  precision.
378  @end deffn  @end deffn
379    
380    @deffn {Scheme Procedure} inf? x
381    Return @code{#t} if @var{x} is either @samp{+inf.0} or @samp{-inf.0},
382    code @var{#f} otherwise.
383    @end deffn
384    
385    @deffn {Scheme Procedure} nan? x
386    Return @code{#t} if @var{x} is @samp{+nan.0}, code @var{#f} otherwise.
387    @end deffn
388    
389  @node Complex Numbers  @node Complex Numbers
390  @subsection Complex Numbers  @subsection Complex Numbers
# Line 491  all real numbers in Guile are also ratio Line 532  all real numbers in Guile are also ratio
532  limited number of decimal places, say N, can be made into an integer by  limited number of decimal places, say N, can be made into an integer by
533  multiplying by 10^N.  multiplying by 10^N.
534    
535    Guile also understands the syntax @samp{+inf.0} and @samp{-inf.0} for
536    plus and minus infinity, respectively.  The value must be written
537    exactly as shown, that is, the always must have a sign and exactly one
538    zero digit after the decimal point.  It also understands @samp{+nan.0}
539    and @samp{-nan.0} for the special 'not-a-number' value.  The sign is
540    ignored for 'not-a-number' and the value is always printed as @samp{+nan.0}.
541    
542  @node Integer Operations  @node Integer Operations
543  @subsection Operations on Integer Values  @subsection Operations on Integer Values

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26