[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

R3RS number syntax



I have a few questions about the syntax of numbers in R3RS Scheme:

1. The sequence of characters ``#x3e4'' has two very different parses.  The
question is whether or not the ``e'' is a digit or the exponent marker.  What is
intended here?

2.  What is the meaning of the exponent part when the radix is not 10?  My guess
was that ``#O3E4'' meant 3 times 8 to the 4th, but C-Scheme, at least, treats
this as 3 times 10 to the 4th.  I can guess from the syntax that the digits of
the exponent are always in radix 10 (since the base 10 digits are all that's
allowed there), but what is the base for the exponentiation?  I thought it would
be more useful if the exponentiation base was the same as the number radix (so
that, for example, I could say #b1E20 to make a mask that has only bit 20 turned
on).

3.  Does ``3/4e5'' mean the same as ``75000'' or ``.0000075''?  That is, is the
exponent intended to apply to the entire rational ``3/4'' or just to the
denominator?

4.  Does ``123##.##'' mean anything different from ``12300'' when read?  Or does
it really mean the same as ``#i12300''?

5.  I assume that the syntax ``3@4'' is meant to denote the complex number with
magnitude 3 and angle 4, but this isn't actually said anywhere in the document.
The same goes for the (assumed rectangular) notation ``3+4i'', though it's more
clear in that case.  I had to infer the meaning from an example in the
description of number-printing formats.

It would really be nice if R4RS were to include a formal semantics for the
syntax of numbers.  I realize that some issues (such as whether or not such a
literal is exact) are intended to be implementation-dependent, but I think that
there could be a semantics that defined the mathematical number that each input
syntax is intending to represent (perhaps the semantic function should return an
interval of the reals for each expansion of the <real> nonterminal in the
grammar).

	Pavel