OT (partially): about promotion of integers

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Dec 11 08:22:14 PST 2012


On 12/11/12 10:20 AM, eles wrote:
> Hello,
>
> The previous thread, about the int resulting from operations on bytes,
> rised me a question, that is somewhat linked to a difference between
> Pascal/Delphi/FPC (please, no flame here) and C/D.
[snip]

There's a lot to be discussed on the issue. A few quick thoughts:

* 32-bit integers are a sweet spot for CPU architectures. There's rarely 
a provision for 16- or 8-bit operations; the action is at 32- or 64-bit.

* Then, although most 64-bit operations are as fast as 32-bit ones, 
transporting operands takes twice as much internal bus real estate and 
sometimes twice as much core real estate (i.e. there are units that do 
either two 32-bit ops or one 64-bit op).

* The whole reserving a bit and halving the range means extra costs of 
operating with a basic type.


Andrei


More information about the Digitalmars-d mailing list