On Wednesday, 14 July 2021 at 17:29:04 UTC, Ali Çehreli wrote:
On 7/14/21 2:44 AM, wjoe wrote:
>> x = (x ^^ y).to!(typeof(x));
>> }
>>
>> For example, run-time error if y == 7.
> I was planning on adding support for over-/underflow bits but
this is
> much better. Thanks!
If so, then there is
On 7/14/21 2:44 AM, wjoe wrote:
>> x = (x ^^ y).to!(typeof(x));
>> }
>>
>> For example, run-time error if y == 7.
> I was planning on adding support for over-/underflow bits but this is
> much better. Thanks!
If so, then there is also std.experimental.checkedint:
https://dlang.org/phobos/s
On Tuesday, 13 July 2021 at 15:14:26 UTC, Ali Çehreli wrote:
On 7/13/21 4:12 AM, wjoe wrote:
> ```D
> byte x = some_val;
> long y = some_val;
>
> x ^^= y; // Error: cannot implicitly convert expression
> pow(cast(long)cast(int)x, y) of type long to byte
[...]
> I rewrote it to something like
>
On 7/13/21 4:12 AM, wjoe wrote:
> ```D
> byte x = some_val;
> long y = some_val;
>
> x ^^= y; // Error: cannot implicitly convert expression
> pow(cast(long)cast(int)x, y) of type long to byte
[...]
> I rewrote it to something like
> ```D
> mixin("x = cast(typeof(x))(x" ~ op[0..$-1] ~ " y);");