[comp.lang.scheme] R3RS number syntax

Pavel.pa@XEROX.COM (04/28/88)

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

freeman@spar.SPAR.SLB.COM (Jay Freeman) (05/02/88)

In article <880427-173044-6364@Xerox> Pavel.pa@XEROX.COM writes:

>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,

	Mine, too.  I always thought of exponents as being merely a
    notational convenience for inconveniently-placed radix points.

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

	I think the system should try to arrange that when it reads
    (and evals) something that it printed out, the object created
    should be as indistinguishable as possible from the one printed.
    (This is of course an impossible goal, if only because you can
    always print a number with fewer digits of precision than are
    implicit in its internal representation; or because you can
    print an inexact "1" as an integer with exactness surpressed.)
    I also think the purpose of the "exact" bit is very low-level;
    I believe it is intended to flag that all information necessary
    to describe a number completely is contained in the particular
    bit-pattern that represents the number in store.
	If that is true, then the system should NEVER print "#"s
    in any representation of an exact number.  Thus for example,
    if you asked for the exact rational 1/3 to be printed as a
    decimal with six million digits of precision, you should get
    lots and lots of "3"s, even though no likely internal
    representation of a flonum has that much precision.
	So if the system prints "123##.##", the number printed
    must originally have been inexact.  Thus I think the reader
    ought to treat "123##.##" as an inexact number.
	
	Don't take me as an authority, I certainly am not!

	It seems more natural to me to interpret 3/4e6 as (3/4)e6,
    but I certainly don't see anything in the R3 report to require it.

    By the way, what does C-Scheme say to "(integer?  1.0)"?  To "(integer?
1)"?  MacScheme (version 1.51) says the former is false and the latter true;
I think both should be true.  (MacScheme does say that "(= 1 1.0)" is true
so I am not just a victim of roundoff.)


					-- Jay Freeman

<canonical disclaimer -- these are personal opinions only>

freeman@spar.SPAR.SLB.COM (Jay Freeman) (05/05/88)

In article <880427-173044-6364@Xerox> Pavel.pa@XEROX.COM writes:

>It would really be nice if R4RS were to include a formal semantics for the
>syntax of numbers.

The more I think about it, the more glaring that omission looks.  The
R3 report provides a perfectly adequate BNF for determining whether or
not a particular token represents a number, but provides no hint how
to tell *which* number.

						-- Jay Freeman

<canonical disclaimer -- these are personal opinions only>