What the heck am i doing wrong? I'm just trying to create a 8 bit unsigned variable.
kdevel
kdevel at vogtner.de
Wed May 21 18:54:04 UTC 2025
On Friday, 16 May 2025 at 19:19:41 UTC, H. S. Teoh wrote:
> For example, how do you negate a ubyte?
Mathematically this is only defined for 0 over the range of
ubyte.
> Obviously, you can't do this:
>
> ```
> ubyte a;
> a -=;
> ```
>
> But writing it as `a = -a;` runs into the same error, for the
> same reason.
>
> Instead, you have to work around it with this baroque
> periphrasis:
>
> ```
> ubyte a;
> a = cast(ubyte) -a;
> ```
>
> Does it make sense?
How about:
```
a *= -1;
```
?
More information about the Digitalmars-d-learn
mailing list