[OT] The Usual Arithmetic Confusions

jmh530 john.michael.hall at gmail.com
Sun Feb 6 12:09:55 UTC 2022


On Saturday, 5 February 2022 at 07:59:21 UTC, Ola Fosheim Grøstad 
wrote:
> [snip]
>
> Well written code would use a narrowing cast with checks for 
> debugging, but the type itself is less interesting, so it would 
> be better with overloading on return type. But it could be the 
> default if overflow checks were implemented.
>
>     byte x = narrow(expression);
>
>
> If it was the default, you could disable it instead:
>
>    byte x = uncheck(expression);

In the meantime, the equivalent of the `narrow` function could 
get added to `std.conv`.


More information about the Digitalmars-d mailing list