small doc edits

svn: r6586
This commit is contained in:
Matthew Flatt 2007-06-12 06:12:18 +00:00
parent 5d5a90c4e1
commit 1ce06cc65a
4 changed files with 19 additions and 5 deletions

View File

@ -5,6 +5,7 @@
max-width: 35em; max-width: 35em;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
padding-left: 0.5em;
font-family: Times; font-family: Times;
} }

View File

@ -76,9 +76,10 @@ types of numbers.
(inexact->exact 0.1) (inexact->exact 0.1)
] ]
Inexact results are also produced by trancendental procedures such as Inexact results are also produced by procedures such as @scheme[sqrt],
@scheme[sin] and @scheme[cos], in part because Scheme can only @scheme[log], and @scheme[sin] when an exact result would require
represent rational numbers. representing real numbers that are not rational. Scheme can represent
only rational numbers and complex numbers with rational parts.
@examples[ @examples[
(code:line (sin 0) (code:comment #, @t{rational...})) (code:line (sin 0) (code:comment #, @t{rational...}))
@ -133,4 +134,16 @@ compares numbers considering both exactness and numerical equality.
(eqv? 1 1.0) (eqv? 1 1.0)
] ]
Beware of comparisons involving inexact numbers, which by their nature
can have surprising behavior. Even apparently simple inexact numbers
may not mean what you think they mean; for example, while a base-2
IEEE floating-point number can represent @scheme[1/2] exactly, it
can only approximate @scheme[1/10]:
@examples[
(= 1/2 0.5)
(= 1/10 0.1)
(inexact->exact 0.1)
]
@refdetails["mz:numbers"]{numbers and number procedures} @refdetails["mz:numbers"]{numbers and number procedures}

View File

@ -11,7 +11,7 @@
A @defterm{pair} joins two arbitrary values. The @scheme[cons] A @defterm{pair} joins two arbitrary values. The @scheme[cons]
procedure constructs pairs, and the @scheme[car] and @scheme[cdr] procedure constructs pairs, and the @scheme[car] and @scheme[cdr]
procedures extract the first and second elements of the pair, procedures extract the first and second elements of the pair,
respectively. The @scheme[pair?] predicate recogizes pairs. respectively. The @scheme[pair?] predicate recognizes pairs.
Some pairs print by wrapping parentheses around the printed forms of Some pairs print by wrapping parentheses around the printed forms of
the two pair elements, putting a @litchar{.} between them. the two pair elements, putting a @litchar{.} between them.

View File

@ -61,7 +61,7 @@ infinity, or @scheme[+nan.0] if no such limit exists.
A @pidefterm{fixnum} is an exact integer whose two's complement A @pidefterm{fixnum} is an exact integer whose two's complement
representation fit into 31 bits on a 32-bit platform or 63 bits on a representation fit into 31 bits on a 32-bit platform or 63 bits on a
64-bit platform. Two fixnums that are @scheme[=] are also the same 64-bit platform. Two fixnums that are @scheme[=] are also the same
according to @scheme[eq?]. Otherwise, the result of @scheme{eq?} according to @scheme[eq?]. Otherwise, the result of @scheme[eq?]
applied to two numbers is undefined. applied to two numbers is undefined.
Two numbers are @scheme[eqv?] when they are both inexact or both Two numbers are @scheme[eqv?] when they are both inexact or both