Time to move std.experimental.checkedint to std.checkedint ?
Walter Bright
newshound2 at digitalmars.com
Tue Mar 30 00:17:44 UTC 2021
On 3/29/2021 2:05 PM, Paul Backus wrote:
> On Monday, 29 March 2021 at 20:00:03 UTC, Walter Bright wrote:
>> D's integral promotion rules (bytes and shorts are promoted to ints before
>> doing arithmetic) get rid of the bulk of likely overflows. (It's ironic that
>> the integral promotion rules are much maligned and considered a mistake, I
>> don't share that opinion, and this is one of the reasons why.)
>
> Well...sometimes they do:
>
> auto result = int.max + int.max;
> writeln(typeof(result).stringof); // int
> writeln(result); // -2
I wrote "the bulk of", not "all"
> The main issue with D's integer promotion rules is that they're inconsistent.
> Sometimes truncating the result of an expression requires an explicit cast, and
> sometimes it doesn't.
Without an example, I don't know what you mean.
More information about the Digitalmars-d
mailing list