Re: Error with implicit cast of ^^=

2021-07-15 Thread wjoe via Digitalmars-d-learn
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

Re: Error with implicit cast of ^^=

2021-07-14 Thread Ali Çehreli via Digitalmars-d-learn
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

Re: Error with implicit cast of ^^=

2021-07-14 Thread wjoe via Digitalmars-d-learn
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 >

Re: Error with implicit cast of ^^=

2021-07-13 Thread Ali Çehreli via Digitalmars-d-learn
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);");