POV-Ray : Newsgroups : povray.off-topic : C/C++ Data Type Ambiguity Backwards : Re: C/C++ Data Type Ambiguity Backwards Server Time
8 Jul 2024 09:00:25 EDT (-0400)
  Re: C/C++ Data Type Ambiguity Backwards  
From: Anthony D  Baye
Date: 23 Aug 2015 18:05:01
Message: <web.55da42f631c53d072aaea5cb0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Okay, I guess everyone who has ever touched C or C++ has at least heard
> rumors of this: The standard data types, such as "int", "short int" or
> "long int", are anything but. For instance, a "long int" will typically
> be 32 bits wide on a 32 bit machine, but 64 bits on a 64 bit machine -
> unless you're running Windows, in which case it's still 32 bit. And
> "int" will typically be 32 bits wide - unless you're running on a 64 bit
> Cray machine, in which case it will be a whopping 64 bit as well. Or on
> an embedded computer, in which case it may be as small as 16 bits. Hell,
> there are even systems out there where the most fundamental data type,
> "char", is not 8 but 16 bits wide!
>
char, according to wikipedia, is supposed to be exactly one byte.  Byte is
defined, in turn, to be large enough to carry any member of the basic execution
character set and UTF-8 code units. This implies that it must be at least 8 bits
wide.

POSIX requires it to be exactly 8 bits, but the exact number of bits can be
checked with CHAR_BIT from limits.h (or <climits>). It should be 8 bits on most
systems.

Regards,
A.D.B.


Post a reply to this message

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