Cardinal numbers or unsigned int.. 
Author Message
 Cardinal numbers or unsigned int..

>I guess it's a question of style.  I personally don't like unsigned int
>because it's two words and it's too long.

This is funny.  Do you avoid everything that's two words?  The canonical name
of the type is `unsigned int'.  If you think that's too long, you can call it
what you want.  A common typedef is `u_int', used in the Unix kernel.

Begin tirade...

So what the heck is an `int'?  Accoding to K&R, it's a bit pattern ``of the
natural size for integer arithmetic on a given machine''.  Similarly, a
`float' is a ``single precision floating-point number''.  These types are
explicitly defined and named in terms of low-level machine resources.

I think this is something Pascal and Modula-2 got wrong.  Calling a machine
word an `INTEGER' or `CARDINAL' and a floating-point number a `REAL' is a lie.
I know what an integer is, and when you add two positive ones you better get
another positive one.  Similarly, real numbers obey associativity and similar
laws which floating-point numbers do not.

Furthermore, this naming paves over the distinction between abstract data
types and their implementations.  I think this is a bad thing to teach people
who are learning to program.  The world is full of things that{*filter*}up with
more than 32767 (or 255 or 2147483647) of something.  We need less of this,
and Pascal confusing the issue isn't going to help any.

At least C is honest about its type names.  Demand `truth in advertising'.

Mon, 16 Nov 1992 06:56:05 GMT  
 [ 1 post ] 

 Relevant Pages 

1. CARDINAL and INTEGER number in Mod-2

2. Cardinal numbers

3. Cardinal number output

4. int divided by unsigned.

5. 64-bit unsigned int <--> QuadWord

6. unsigned int --> xxm0

7. unsigned int in f77

8. Problems with unsigned int's...

9. Unsigned Int in Lahey Fortran?

10. Unsigned number->string?

11. Signed and Unsigned numbers?

12. Newbie question......Unsigned and signed numbers


Powered by phpBB® Forum Software