Sujet : Re: "A diagram of C23 basic types"
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 04. Apr 2025, 05:05:36
Autres entêtes
Organisation : None to speak of
Message-ID : <858qogk1v3.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Gnus/5.13 (Gnus v5.13)
Lawrence D'Oliveiro <
ldo@nz.invalid> writes:
On Wed, 2 Apr 2025 16:33:46 +0100, bart wrote:
Here, tell me at a glance the magnitude of
this number:
10000000000
>
#define THOUSAND 1000
#define MILLION (THOUSAND * THOUSAND)
#define BILLION (THOUSAND * MILLION)
>
uint64 num = 10 * BILLION;
>
Much easier to figure out, don’t you think?
On my system (when I change uint64 to uint64_t and add the
appropriate #include directives) I get a compile-time warning and num
is 1410065408. On a system with 16-bit int (uncommon outside small
embedded systems these days), THOUSAND * THOUSAND would overflow.
Whereas 10000000000 (or 10'000'000'000) will have a type big enough
to hold its value.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */