binary constants (??)

Karl Heuer karl at haddock.ima.isc.com
Tue Dec 5 09:41:59 AEST 1989


In article <1989Nov29.164913.1794 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>For some reason, I've never had cause to write numbers in (say) base 19.

Interestingly enough, I once needed to write some constants whose natural
radix was 64 (and, due to the context, none of the radix-64 digits would ever
exceed the value of 'Z').  When I tried to make use of the arbitrary-radix
feature built into the language I was using at the time (using the notation
ddddB64), it triggered a compiler bug.

>I wonder if the added generality really buys you anything, given that it
>does introduce a new class of subtle errors.  (How many programs would
>notice if 16r19 was mistyped as 15r19?  Or 19r16?)

It doesn't seem any worse than the problem of accidentally putting a leading
zero on a number intended to be decimal.  Anyway, a partial solution is to
have the compiler optionally warn about the use of an "obscure" radix.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint
(Bonus question: identify the language, operating system, and university where
I had use for radix 64.  No, I *don't* mean radix 40 aka RAD50.)



More information about the Comp.lang.c mailing list