Theiling Online    Sitemap    Conlang Mailing List HQ    Attic   

Re: OT: Number bases

From:Mark J. Reed <markjreed@...>
Date:Wednesday, February 11, 2009, 15:17
On Wed, Feb 11, 2009 at 7:03 AM, Henrik Theiling <theiling@...> wrote:
> Ternary logic would also eliminate those awful hacks from computer > languages: unsigned numbers. They are a major cause for serious bugs > like buffer overflows and integer underflows.
Natural and nonnegative numbers weren't invented for the convenience of programmers, ya know. There's a bit of precomputer history there. :) Of course the primary motivation for unsigned integer types in computer programming is space savings. By shifting the range from (roughly) centered on 0 to having a minimum at 0, you double the maximum value without using any more space, at the cost of not having negative numbers available - which for many applications is not a handicap at all. My weight in pounds fits in an unsigned byte; to fit it into a signed byte I have to convert to kg. :)
> Humans just don't care whether a number is signed or unsigned (and rightly so), so > programmers make mistakes.
But humans also sometimes don't care whether a number is positive or negative. Two things here... 1) Conflating programmer interface with hardware architecture. Any high-level language should have support available for arbitrarily-large-magnitude integers, rationals, arbitrarily-precise approximations to reals, complex numbers, etc. But those don't all need to correspond to native machine types. 2) Solving the wrong problem. As a programmer, sometimes I want sqrt(-1) to quietly return i so I can go about my business; at other times I want it to scream bloody murder because a complex answer doesn't make any sense. Knowing the difference is hard; making the language and/or hardware able to deal with complex numbers doesn't solve the programming problem. At worst, it hides the programming problem so that it goes unnoticed until a bug is tripped. -- Mark J. Reed <markjreed@...>

Reply

Henrik Theiling <theiling@...>