largest int on different platforms

NOTE: The netcdf-hdf mailing list is no longer active. The list archives are made available for historical reasons.

Hi Ed,
Largest signed `long long' is a bit pattern where all bits are set
except the most significant bit:

#define LL_MAX \
   ((long long)((1ULL<<(8*sizeof(long long)-1))-1))

Largest unsigned long long is all bits set. In other words, the
stuff above bit-ORed with the most significant bit:

#define ULL_MAX \
   ((unsigned long long)LL_MAX | (1ULL<<(8*sizeof(long long)-1)))

This will work for any size of these datatypes as long as
sizeof(unsigned long long)==sizeof(long long).

You could also use the constants LLONG_MAX, LLONG_MIN, and ULLONG_MAX
from <limits.h>.

>>>>> "Ed" == Ed Hartnett <ed@xxxxxxxxxxxxxxxx> writes:
Ed> Howdy all!

Ed> What is the maximum long long on different platforms. Anyone know?

Ed> In my header I have:

Ed> #define X_INT64_MAX   ((nc_int64)9223372036854775804)

Ed> This gives me an error on AIX:

Ed> "nc4hdf.c", line 2558.31: 1506-207 (W) Integer constant
Ed> 9223372036854775804 out of range.

Ed> Is there some standard way of determining what the largest signed and
Ed> unsigned 64-bit int is?

Ed> I figure one of you HDF5 people must know, since you have probably had
Ed> the same problems.

Ed> Thanks!

Ed> -- 
Ed> Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx

Robb Matzke L-159   | Ph:  812-967-6325  | I/O, I/O, it's off to disk we go,
Lawrence Livermore  | Fax: 812-967-6326  | A gigabyte to read or write,
National Laboratory | Hrs: 3am-11am PDT  | I/O, I/O.

  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-hdf archives: