Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
December 06, 2005 Large integer division | ||||
---|---|---|---|---|
| ||||
Dividing really big ulongs by each other doesn't seem to work at all. --- void main() { ulong a = 10_000_000_000_000_000, b = 1_000_000_000_000_000; assert (a / b == 10); } --- a / b is, according to writef, 9223372036854775818. |
December 06, 2005 Re: Large integer division | ||||
---|---|---|---|---|
| ||||
Posted in reply to Deewiant | Confirmed: _ULDIV appears to be faulty. "Deewiant" <deewiant.doesnotlike.spam@gmail.com> wrote in message news:dn3old$hhr$1@digitaldaemon.com... > Dividing really big ulongs by each other doesn't seem to work at all. > > --- > void main() { > ulong a = 10_000_000_000_000_000, > b = 1_000_000_000_000_000; > > assert (a / b == 10); > } > --- > > a / b is, according to writef, 9223372036854775818. |
December 07, 2005 Re: Large integer division | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kris | In article <dn4l2u$1joa$1@digitaldaemon.com>, Kris says... > >Confirmed: _ULDIV appears to be faulty. > > >"Deewiant" <deewiant.doesnotlike.spam@gmail.com> wrote in message news:dn3old$hhr$1@digitaldaemon.com... >> Dividing really big ulongs by each other doesn't seem to work at all. >> >> --- >> void main() { >> ulong a = 10_000_000_000_000_000, >> b = 1_000_000_000_000_000; >> >> assert (a / b == 10); >> } >> --- >> >> a / b is, according to writef, 9223372036854775818. > There looks to be a problem with longs as well (__LDIV__). |
December 07, 2005 Re: Large integer division | ||||
---|---|---|---|---|
| ||||
Posted in reply to Deewiant | Deewiant wrote:
> Dividing really big ulongs by each other doesn't seem to work at all.
>
> ---
> void main() {
> ulong a = 10_000_000_000_000_000,
> b = 1_000_000_000_000_000;
>
> assert (a / b == 10);
> }
> ---
>
> a / b is, according to writef, 9223372036854775818.
FWIW, Both "long" and "ulong" works fine with GDC
import std.stdio;
int main() {
ulong a = 10_000_000_000_000_000,
b = 1_000_000_000_000_000;
assert (a / b == 10);
debug writefln(a / b);
long c = -42_000_000_000_000_000,
d = 1_000_000_000_000_000;
assert (c / d == -42);
debug writefln(c / d);
return 0;
}
prints:
10
42
--anders
|
December 07, 2005 Re: Large integer division | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders F Björklund | > prints:
> 10
> 42
<duh> -42
--anders
|
December 09, 2005 Re: Large integer division | ||||
---|---|---|---|---|
| ||||
Posted in reply to Deewiant | "Deewiant" <deewiant.doesnotlike.spam@gmail.com> wrote in message news:dn3old$hhr$1@digitaldaemon.com... > Dividing really big ulongs by each other doesn't seem to work at all. Criminy! You're right. I have it fixed, it'll go out in the next update. |
December 10, 2005 Re: Large integer division | ||||
---|---|---|---|---|
| ||||
Posted in reply to Deewiant Attachments: | Deewiant schrieb am 2005-12-06: > Dividing really big ulongs by each other doesn't seem to work at all. > > --- > void main() { > ulong a = 10_000_000_000_000_000, > b = 1_000_000_000_000_000; > > assert (a / b == 10); > } > --- > > a / b is, according to writef, 9223372036854775818. Added to DStress as http://dstress.kuehne.cn/run/o/opDiv_13_A1.d http://dstress.kuehne.cn/run/o/opDiv_13_A2.d http://dstress.kuehne.cn/run/o/opDiv_13_B1.d http://dstress.kuehne.cn/run/o/opDiv_13_B2.d http://dstress.kuehne.cn/run/o/opDiv_13_C1.d http://dstress.kuehne.cn/run/o/opDiv_13_C2.d http://dstress.kuehne.cn/run/o/opDiv_13_D1.d http://dstress.kuehne.cn/run/o/opDiv_13_D2.d Thomas |
Copyright © 1999-2021 by the D Language Foundation