POV-Ray : Newsgroups : povray.off-topic : C/C++ Data Type Ambiguity Backwards : Re: C/C++ Data Type Ambiguity Backwards Server Time
5 Jul 2024 09:26:53 EDT (-0400)
  Re: C/C++ Data Type Ambiguity Backwards  
From: Le Forgeron
Date: 23 Aug 2015 12:24:55
Message: <55d9f3d7@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Le 23/08/2015 10:54, Orchid Win7 v1 a écrit :
> On 21/08/2015 01:12 PM, clipka 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.
> 
> If I'm remembering my history right, C was basically invented to
> write Unix in. From the very beginning, it was a programming
> language *specifically designed* for system programming.
> 

But it had to deal with at least two machines, PDP-11 with 16 bits
capability (the registers where 16 bits, long integers took 2
registers, for 32 bits), and some fancy machines with 9 bits per byte,
providing 18 bits for native integers.

In such a time with different hardwares, adaptation of the language
was the PITA.

> You know, the kind of programming where knowing exactly how many
> bits you're dealing with is 100% critical.

C language provided a common minimal set of assertion:
 at least 8 bits per char (but you can have more)
 at least 16 bits per short
 int is at least as large as short, and long int at least 32 bits.

and btw, signed integer value could, or not, be using the complement
to 2 (or 1, or anything else).

float and double... another story. (I know of a C compiler on a system
which use 48 bits for one of them, nothing like the usual 32 and 64
bits you can get used to). Ieee-757 can be used, or not.

> 
> And yet, this is one of the few programming languages on Earth
> which doesn't guarantee how many bits are in a particular data
> type, and provides no way to specify what you actually want.

And where you have a hell of time to determine if you are on a little
endian, big endian, mixed endian... until you smash an union in the scop
e.

> 
> Does that seem weird to anybody else??

You expect control... the target was easing port of bigger code,
including the compiler itself. At that time, porting code was costing
so much (in time & money).

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iJwEAQEIAAYFAlXZ89YACgkQhKAm8mTpkW0CxQP/W5OTI5c0RDb4TABmOkWmbLp1
Puttcb9mydP3uudq+BEKOeesMkOEO0j/r2gBGNAJHQdDAx1KrO8AYmpB2315TMrp
pajSI316MdCiXL+DtkFyGHLqNXnIR7EWm8j6fXQomD8UKuClo3WFzoK50aYntXC9
e3bQ9x3WZBEp2o4TiH0=
=gdYK
-----END PGP SIGNATURE-----


Post a reply to this message

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