I learned this lesson when int was 16 bit, and short was the same as
char. 

        I'm old. 

        The lesson, by the way, is that C is a bit rubbish; I recommend using
named size integer types, like u64 (or possibly uint64_t, or some
other "standard", perhaps). 

        Ideally, a language should allow you to declare integer variables
like 0..100, 1..7, 1..12, etc. (and ensure any value written fits),
but there you go.  

          Von: Aleksandar Kuktin <[email protected]>
 An: [email protected]
 Betreff: [fun] unsigned int is not big enough
 Datum: Fri, 07 Sep 2012 22:59:51 +0200

 I just ran into a fun little thing I thought I ought to share with
 people.

 I am writing a program for calculating the standardised mortality
rates
 from various diseases, when I noticed that an unsigned int as well as
 an unsigned long on 32-bit x86 architectures is simply not big
enough.

 On x86_32, both are 4 octets wide, while on x86_64, only int is 4
 octets wide. That means they can store values up to 2**32-1 which is
 about 4.3 billion which is NOT ENOUGH if you want to calculate
 world-wide statistics!

 And there I was, foolishly believing that unsigned int so BIG, that I
 will never in my life really have to worry about its size. Oh, what a
 fool I was.

 -- 
 Fourth law of programming:
 Anything that can go wrong wi
 sendmail: segmentation violation - core dumped
 -- 
 http://linuxfromscratch.org/mailman/listinfo/lfs-chat [1]
 FAQ: http://www.linuxfromscratch.org/faq/ [2]
 Unsubscribe: See the above information page

Links:
------
[1]
?ctl=dereferer&amp;to=aHR0cDovL2xpbnV4ZnJvbXNjcmF0Y2gub3JnL21haWxtYW4vbGlzdGluZm8vbGZzLWNoYXQ%3D
[2]
?ctl=dereferer&amp;to=aHR0cDovL3d3dy5saW51eGZyb21zY3JhdGNoLm9yZy9mYXEv
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-chat
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to