0nnn octal notation considered harmful

Stewart Gordon smjg_1998 at yahoo.com
Wed Feb 16 07:09:36 PST 2011


On 12/02/2011 18:27, Don wrote:
> spir wrote:
<snip>
>> Copying a string'ed integer is indeed not the only this notation is bug-prone: prefixing
>> a number with '0' should not change its value (!).

Indeed.  Even more confusing is that when it's a floating point it doesn't.  But see
http://d.puremagic.com/issues/show_bug.cgi?id=3251

>> Several programming languages switched to another notation; like 0onnn, which is
>> consistent with common hex & bin notations and cannot lead to misinterpretation. Such
>> a change would be, I guess, backward compatible; and would not be misleading for C
>> coders.

Indeed, does anyone know why the 0xxx notation was chosen in the first place?

> Octal should just be dropped entirely. Retaining built-in octal literals is like retaining
> support for EBCDIC. It's a relic of a time before hexadecimal was invented.

I once recall hearing that octal's main use lay on old mainframes that worked in 15-bit 
units.

But it lives on in Unix file permission settings.  And is it still the form of CompuServe 
user IDs?

Stewart.


More information about the Digitalmars-d mailing list