Re: OT: Number bases
From: | Henrik Theiling <theiling@...> |
Date: | Thursday, February 12, 2009, 14:21 |
Hi!
Chris Wright writes:
>>...
>> So I can still rightfully hope for ternary computers to eliminate
>> unsigned ints! Maybe one day, when Moore's law will have failed us,
>> someone finds some trick that can make electronic circuits smaller,
>> but only if they use ternary logic.
>
> No, it'll be like floating point arithmetic: a processor will have
> separate circuitry for signed and unsigned math.
Nonono, please don't say that!
>...
> What programming language do you use that allows writing binary
> integer literals with a 0b prefix?
Many C compilers for embedded systems have that. And gcc seems to
have introduced it, too:
http://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html
The docs are for gcc 4.4.0. I cannot check: I only have gcc 4.2 here,
but it does not parse binary numbers, neither in C nor in C++ mode, it
seems.
>...
> So it would express 97 as (1*81) + (0*27) + (1*9) + (2 * 3) + (1*1)?
Yes. That's a small Latin letter 'a'. But it would leave out any
space if possible, rely on operator preference, and 'optimise' a bit:
c=((char)(81+9+2*3+1));
Instead of:
c= 'a';
**Henrik
Reply