On Sunday, 29 August 2021 at 16:21:40 UTC, jfondren wrote:
... after Phobos is patched.
```
error: undefined identifier ‘Lhs’, did you mean alias ‘Rhs’?
```
Shows how much anyone actually uses this code, I guess--the bug
was introduced [in 2017][1], and as far as I can tell has never
even
On Sunday, 29 August 2021 at 15:57:18 UTC, Paul Backus wrote:
On Sunday, 29 August 2021 at 15:42:18 UTC, Ali Çehreli wrote:
Depending on the situation, you may want to use std.conv.to,
which does a value range check and throws an exception to
prevent an error:
byte foo(byte a, byte b) {
On Sunday, 29 August 2021 at 15:42:18 UTC, Ali Çehreli wrote:
Depending on the situation, you may want to use std.conv.to,
which does a value range check and throws an exception to
prevent an error:
byte foo(byte a, byte b) {
import std.conv : to;
return (a + b).to!byte;
}
On 1/18/19 9:09 AM, Mek101 wrote:
> source/hash.d(11,25): Error: cannot implicitly convert expression
> `cast(int)temp[fowardI] + cast(int)temp[backwardI]` of type `int` to
`byte`
Others suggested casting as a solution which works but it will hide
potential errors.
Depending on the
On 8/29/21 3:57 AM, Rekel wrote:
On Friday, 18 January 2019 at 18:49:23 UTC, Steven Schveighoffer wrote:
As others have said, those are the rules D has for historical reasons,
you just have to deal with them.
Is that to ensure compatibility with C?
Yes. It's mentioned multiple times in
On Friday, 18 January 2019 at 18:49:23 UTC, Steven Schveighoffer
wrote:
As others have said, those are the rules D has for historical
reasons, you just have to deal with them.
Is that to ensure compatibility with C?
On Fri, Jan 18, 2019 at 01:49:23PM -0500, Steven Schveighoffer via
Digitalmars-d-learn wrote:
> On 1/18/19 12:26 PM, Mek101 wrote:
[...]
> > Then why isn't int + int = long? If i did the example above, they
> > wouldn't fit in a int for sure, yet the result is of the same type.
> > Why should
On 1/18/19 12:26 PM, Mek101 wrote:
On Friday, 18 January 2019 at 17:15:09 UTC, Steven Schveighoffer wrote:
What is 127 + 127? Answer: 254. Which if converted to a byte is -127.
Not what you might expect if you are doing addition.
Quite similar to int.max + int.max
Indeed. But this is where
On Friday, 18 January 2019 at 17:26:35 UTC, Mek101 wrote:
Then why isn't int + int = long? If i did the example above,
they wouldn't fit in a int for sure, yet the result is of the
same type. Why should byte be any different?
Because C didn't define it that way. And C didn't define it that
On Fri, Jan 18, 2019 at 05:26:35PM +, Mek101 via Digitalmars-d-learn wrote:
> On Friday, 18 January 2019 at 17:15:09 UTC, Steven Schveighoffer wrote:
> > What is 127 + 127? Answer: 254. Which if converted to a byte is
> > -127. Not what you might expect if you are doing addition.
>
> Quite
On Fri, Jan 18, 2019 at 05:09:52PM +, Mek101 via Digitalmars-d-learn wrote:
> I have the following line of code:
>
> temp[fowardI] = temp[fowardI] + temp[backwardI];
>
> Where temp is a byte array (byte[]). When I try to compile it dmd
> gives me this error:
>
>
On Friday, 18 January 2019 at 17:09:52 UTC, Mek101 wrote:
Where temp is a byte array (byte[])
Oh btw, D's byte is signed, range -128 to 127, unlike C# where it
is unsigned.
C#'s `byte` is represented as D's `ubyte` (meaning "unsigned
byte"), range 0-255.
On Friday, 18 January 2019 at 17:15:09 UTC, Steven Schveighoffer
wrote:
What is 127 + 127? Answer: 254. Which if converted to a byte is
-127. Not what you might expect if you are doing addition.
Quite similar to int.max + int.max
In fact, D promotes all integral types smaller than int to int
On Friday, 18 January 2019 at 17:09:52 UTC, Mek101 wrote:
Meaning that the byte type doesn't have a + operator.
Well, it DOES have a + operator, it just returns int that can be
squished to a size if and only if the compiler proves it fits.
A bit of background: the C language was designed on
On 1/18/19 12:09 PM, Mek101 wrote:
I have the following line of code:
temp[fowardI] = temp[fowardI] + temp[backwardI];
Where temp is a byte array (byte[]). When I try to compile it dmd gives
me this error:
source/hash.d(11,25): Error: cannot implicitly convert expression
15 matches
Mail list logo