POV-Ray : Newsgroups : povray.off-topic : C/C++ Data Type Ambiguity Backwards : Re: C/C++ Data Type Ambiguity Backwards Server Time
5 Jul 2024 08:07:44 EDT (-0400)
  Re: C/C++ Data Type Ambiguity Backwards  
From: clipka
Date: 23 Aug 2015 00:19:55
Message: <55d949eb$1@news.povray.org>
Am 22.08.2015 um 20:16 schrieb Anthony D. Baye:

> I've heard about this (Except for the char thing... that's just weird) but never
> given it much thought. (Short sighted maybe)

Would that be signed or unsigned short sighted? :-P

> I know that Qt Widgets provides it's own fixed width data types, but the C99
> stdint.h had them too.

C++11 <cstdint> has them as well. (*)

Alas, C++03 is based on pre-99 C, so it doesn't have them. So POV-Ray
does its best to try and figure out matching types, but may have to fall
back to relying on the guaranteed minimum widths of the char, short,
int, long and long long types.


----------------------------
(*)

BTW, it should be noted that actually <stdint.h> or <cstdint> does *not*
necessarily have those standard fixed width data types "intN_t" and
"uintN_t" with N={8,16,32,64}, as they are only mandatory if the runtime
environment happens to supports integers of that exact width; in ILP64
environments, for instance, you could theoretically miss out on N=32
(presuming short is 16 bits wide).

Also, all the "intN_t" are unavailable if the runtime environment does
not use two's complement format for negative integers.

The only thing we're guaranteed to get are "intN_least_t",
"uintN_least_t", "intN_fast_t" and "uintN_fast_t", with N={8,16,32,64},
which are /at least/ N bits wide, with the added guarantee that the
"*_least_t" variants are the smallest and the "*_fast_t" variants the
fastest types that fit the bill.

Also note that "intN_least_t" and "intN_fast_t" may be unable to
represent -2^(N-1) (in contrast to "intN_t" which, if present, is
guaranteed to represent exactly the range from -2^(N-1) to 2^(N-1)-1).

So yeah, <stdint.h> alias <cstdint> helps... a tiny bit.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.