On Wednesday, 6 November 2024 at 00:00:48 UTC, Dennis wrote:
On Tuesday, 5 November 2024 at 20:29:08 UTC, Andy Valencia ...
You can also use an assignment operator, which allows overflow without explicit cast:

```D
s *= -1;
```
...

Hi Dennis,

Shouldn't these two act the same?

void main(){
    short i = 1;
    i *= -1;  // Works
i = i*-1; // Gives: Error: cannot implicitly convert expression `cast(int)i * -1` of type `int` to `short`
}

Matheus.

Reply via email to