tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: 64-bit masks



> 1. What is the correct (portable?) way of specifying 64-bit constants?

> If I need a 64-bit constant set to all 1s, will the following work on
> all systems

> unit64_t num = 0xffffffffffffffffULL;

(Well, uint64_t.)  This will work on anything NetBSD runs on.  I'm not
sure whether unsigned long long is guaranteed by C to be at least 64
bits wide.  (Those versions of C that _have_ unsigned long long, that
is; it's a relatively recent addition to the language.)

You might want to write ~0ULL instead; it's smaller and somewhat
clearer.  (Just looking at what you wrote, I have to count characters
to tell you didn't write 0xfffffffffffffffULL instead, for example.)

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index