Re: It is possible to substract 5 from 3 unsigned integer

2020-10-08 Thread Kagamin via Digitalmars-d-learn
On Tuesday, 6 October 2020 at 18:24:14 UTC, Alaindevos wrote: A logical one. For the last one higher classes might be needed. Also assert(5/3==1);

Re: It is possible to substract 5 from 3 unsigned integer

2020-10-08 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 6 October 2020 at 18:24:14 UTC, Alaindevos wrote: There are two subtractions possible. A machine-one which can be architecture dependent, does not have the same results on all computers, and behaves like a modulus in mathematics. A logical one. For the last one higher classes might

Re: It is possible to substract 5 from 3 unsigned integer

2020-10-06 Thread Johan via Digitalmars-d-learn
On Tuesday, 6 October 2020 at 18:24:14 UTC, Alaindevos wrote: There are two subtractions possible. A machine-one which can be architecture dependent, does not have the same results on all computers, and behaves like a modulus in mathematics. A logical one. For the last one higher classes might

Re: It is possible to substract 5 from 3 unsigned integer

2020-10-06 Thread ikod via Digitalmars-d-learn
On Tuesday, 6 October 2020 at 18:24:14 UTC, Alaindevos wrote: There are two subtractions possible. A machine-one which can be architecture dependent, does not have the same results on all computers, and behaves like a modulus in mathematics. A logical one. For the last one higher classes might

Re: It is possible to substract 5 from 3 unsigned integer

2020-10-06 Thread Alaindevos via Digitalmars-d-learn
There are two subtractions possible. A machine-one which can be architecture dependent, does not have the same results on all computers, and behaves like a modulus in mathematics. A logical one. For the last one higher classes might be needed.

Re: It is possible to substract 5 from 3 unsigned integer

2020-10-06 Thread Ali Çehreli via Digitalmars-d-learn
On 10/6/20 5:24 AM, Alaindevos wrote: Is that the expected behavior of the programmer? Opinions can differ. Feel free to elaborate. The following is even more "expected". ;) Subtract zero from -1 and you get size_t.max. void main() { int[] arr; int i = -1; auto u = (i - arr.length);

Re: It is possible to substract 5 from 3 unsigned integer

2020-10-06 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 6 October 2020 at 12:24:56 UTC, Alaindevos wrote: Is that the expected behavior of the programmer? Opinions can differ. Feel free to elaborate. It's expected behavior: "If both operands are of integral types and an overflow or underflow occurs in the computation, wrapping will hap

Re: It is possible to substract 5 from 3 unsigned integer

2020-10-06 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 6 October 2020 at 12:24:56 UTC, Alaindevos wrote: Is that the expected behavior of the programmer? Opinions can differ. Feel free to elaborate. Elaborate please. Are you really asking if one can do subtraction in D.

Re: It is possible to substract 5 from 3 unsigned integer

2020-10-06 Thread Alaindevos via Digitalmars-d-learn
On Tuesday, 6 October 2020 at 12:24:56 UTC, Alaindevos wrote: Is that the expected behavior of the programmer? Opinions can differ. Feel free to elaborate. E.g. length of a string unsigned long.

It is possible to substract 5 from 3 unsigned integer

2020-10-06 Thread Alaindevos via Digitalmars-d-learn
Is that the expected behavior of the programmer? Opinions can differ. Feel free to elaborate.