# C90: minimum size of long

Discussion in 'C Programming' started by cpp_novice, Jul 19, 2006.

1. ### cpp_noviceGuest

What is the minimum size of 'long' according to the ANSI 1990 standard?

I thow that c99 requires longs to be atleast 32bits wide.

Is there an electronic copy of the 1990 standard available online?

cpp_novice, Jul 19, 2006

2. ### Tom St DenisGuest

cpp_novice wrote:
> What is the minimum size of 'long' according to the ANSI 1990 standard?
>
> I thow that c99 requires longs to be atleast 32bits wide.
>
> Is there an electronic copy of the 1990 standard available online?

"long" has always been at least upto 2^31 - 1 and down to -2^31.
Unsigned long is at lesst 0...2^32 - 1

Note that doesn't mean that

a) It's incapable of representing things large than 2^31 or 2^32
[resp.]

b) Even if it can only represent upto 2^31/2^32 [resp] that it takes
32 bits to do that [padding/trap bits].

Tom

Tom St Denis, Jul 19, 2006

3. ### Flash GordonGuest

Tom St Denis wrote:
> cpp_novice wrote:
>> What is the minimum size of 'long' according to the ANSI 1990 standard?
>>
>> I thow that c99 requires longs to be atleast 32bits wide.
>>
>> Is there an electronic copy of the 1990 standard available online?

>
> "long" has always been at least upto 2^31 - 1 and down to -2^31.

<pedant>
Actually, it is down to at least -(2^31 - 1). I.e., -2^31 might not be
valid, either due to being a trap on a 2s complement system (which I've
not come across) or due to the use of 1s complement or sign-magnitude.
</pedant>

> Unsigned long is at lesst 0...2^32 - 1
>
> Note that doesn't mean that
>
> a) It's incapable of representing things large than 2^31 or 2^32
> [resp.]
>
> b) Even if it can only represent upto 2^31/2^32 [resp] that it takes
> 32 bits to do that [padding/trap bits].

The rest is all correct as far as I can see.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc

Flash Gordon, Jul 19, 2006
4. ### peteGuest

pete, Jul 19, 2006
5. ### Dik T. WinterGuest

In article <-gordon.me.uk> Flash Gordon <> writes:
....
> Actually, it is down to at least -(2^31 - 1). I.e., -2^31 might not be
> valid, either due to being a trap on a 2s complement system (which I've
> not come across) or due to the use of 1s complement or sign-magnitude.

The Gould NP1.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/

Dik T. Winter, Jul 19, 2006