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

Parsing numbers



I was trying to read some numbers on a MacIvory (Genera 7.4) and
noticed some peculiar behavior.  I got the same results on a 3640
running 7.2.  (In the following examples the LET form was evaled,
the number after ON was entered and the thing after the -> was
returned.  (TYPE-OF *) yielded the thing after the ,)

First a binary example.  This is what one would expect:
 (let ((*read-base* 2)) (read))  on 1111  -> 15 , FIXNUM

I guess this next example is OK in a perverse way, i.e. it would be
correct if 9 were a binary digit with value 8 greater than 1.
 (let ((*read-base* 2)) (read))  on 1191  -> 31 , FIXNUM

Now a hexadecimal example.  Again, this is the expected result:
 (let ((*read-base* 16)) (read))  on 123  -> 291 , FIXNUM

But this next one is wrong.  "A" is a perfectly good hexadecimal digit
and should not be interpreted as an alphabetic.
 (let ((*read-base* 16)) (read))  on 1A3  -> 1A3 , SYMBOL

I expected the second example to result in a symbol named |1191| and
the fourth to result in a number with decimal value 419.  Any relevant
advice on how number parsing does or should work?

Thanks,
--David Hall.
  Hall@ctc.fmc.com
  FMC Corporation
  1205 Coleman Avenue
  Santa Clara, CA 95052