[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Max value of long (platform independent)
From:       Christian Czezatke <e9025461 () student ! tuwien ! ac ! at>
Date:       1998-01-14 13:01:30
[Download RAW message or body]

Hi!

On Wed, 14 Jan 1998, Steffen Hansen wrote:

> On Wed, 14 Jan 1998, Torsten Reuss wrote:
> 
> > Hi there,
> > 
> > since this is the first time I program something platform independent, I
> > have a short question. Does the size (and thus the max value) of long
> > differ on different platforms, and if yes, how do I get the maximum
> > value that a long variable can take? Is there an elegant way (nothing
> > like 2 << (size_of(long)*8-1)-1 or so) ?
> 
> #include <limits.h>
> 
> Then the value you want is called LONG_MAX

And "long" does indeed have different sizes on different platforms, BTW.
For 64bit Un*x platform (Linux/Alpha digital Unix, also some versions of
Irix, AFAIK) a long is 8bytes in size.

In "limits.h" you'll find #define's for various integer types, like

ULONG_MAX
LONG_MAX
LONG_MIN

     Christian


--------------------------------------------------------------------
| Christian Czezatke, Student of Computer Science at the Vienna    |
| University Of Technology.                                        |
|------------------------------------------------------------------|
| email: e9025461@student.tuwien.ac.at                             |
--------------------------------------------------------------------

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic