'int' is enough for 'length' to migrate code from x86 to x64

Kagamin via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 21 01:34:30 PST 2014


On Thursday, 20 November 2014 at 16:03:41 UTC, H. S. Teoh via 
Digitalmars-d wrote:
> By that logic, using an int to represent an integer is also 
> using the
> incorrect type, because a signed type is *also* subject to 
> module 2^^n
> arithmetic -- just a different form of it where the most 
> negative value
> wraps around to the most positive values.

The type is chosen at design time so that it's unlikely to 
overflow for the particular scenario. Why would you want the 
count of objects to reset at some point when counting objects? 
Wrapping of unsigned integers has valid usage for e.g. hash 
functions, but there they are used as bit arrays, not proper 
numbers, and arithmetic operators are used for bit shuffling, not 
for computing some numbers.


More information about the Digitalmars-d mailing list