[comp.std.c] Valid Numbers

jh@pcsbst.UUCP (Johannes Heuft) (07/26/88)

I ran into a similar problem (see 0x47e+barney) when writing a column of
FP numbers which I prepared automatically with the help of an editor.
For convenience, I used a pattern like "0000000.00" and replaced only some
zeroes where appropriate. The result looked like

       0001234.00
or
       0001912.00


The Microsoft C Compiler 5.0 (4.0?) accepted the first number and did the
correct conversion. However the second number caused an error message
saying that a non-octal digit was found in an octal (!!!) number.

Please be aware that I am familiar with scanners, parsers etc. Thus,
I don't need an explanation.

My only question: what does the standard say about well formed numbers?

		Johannes Heuft
		unido!pcsbst!jh

ron@topaz.rutgers.edu (Ron Natalie) (07/27/88)

It's obvious that the Microsoft C compiler is just plain wrong.
First, float numbers are not subject to the leading 0 and 0x
octal interpretation.  Second, even if the number were octal,
8's and 9's (probably not such a good idea) are legal and map
to octal 10's and 11's in that position.

-Ron

guy@gorodish.Sun.COM (Guy Harris) (07/28/88)

> Second, even if the number were octal, 8's and 9's (probably not such a good
> idea) are legal

At least according to the January 11, 1988 draft, 8's and 9's are *not* legal
in octal numbers; check 3.1.3.2 Integer constants.

henry@utzoo.uucp (Henry Spencer) (07/29/88)

In article <Jul.27.10.55.59.1988.7614@topaz.rutgers.edu> ron@topaz.rutgers.edu (Ron Natalie) writes:
>... Second, even if the number were octal,
>8's and 9's (probably not such a good idea) are legal and map
>to octal 10's and 11's in that position.

Well, not any more they aren't legal -- X3J11 has dropped that feature, on
the grounds that nobody likes it and it's hazardous.
-- 
MSDOS is not dead, it just     |     Henry Spencer at U of Toronto Zoology
smells that way.               | uunet!mnetor!utzoo!henry henry@zoo.toronto.edu