[OT] The Usual Arithmetic Confusions
Walter Bright
newshound2 at digitalmars.com
Wed Feb 2 23:27:05 UTC 2022
On 2/2/2022 2:14 PM, Dukc wrote:
> We probably should not even warn on integer promotion. Code that would
> explicitly cast on every place where that is done would be incredibly ugly.
It also *causes* bugs. When code gets refactored, and the types change, those
forced casts may not be doing what is desired, and can do things like
unexpectedly truncating integer values.
One of the (largely hidden because it works so well) advances D has over C is
Value Range Propagation, where automatic conversions of integers to smaller
integers is only done if no bits are lost.
More information about the Digitalmars-d
mailing list