digitalmars.D.bugs - Large integer division
- Deewiant <deewiant.doesnotlike.spam gmail.com> Dec 06 2005
- "Kris" <fu bar.com> Dec 06 2005
- Dave <Dave_member pathlink.com> Dec 06 2005
- =?ISO-8859-15?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> Dec 07 2005
- "Walter Bright" <newshound digitalmars.com> Dec 08 2005
- Thomas Kuehne <thomas-dloop kuehne.cn> Dec 09 2005
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.
Dec 06 2005
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.
Dec 06 2005
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__).
Dec 06 2005
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
Dec 07 2005
prints: 10 42
<duh> -42 --anders
Dec 07 2005
"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.
Dec 08 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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 -----BEGIN PGP SIGNATURE----- iD8DBQFDmlgE3w+/yD4P9tIRAjmDAJ44kwQO0J1E8V2rPCbUHjUpKa/3kQCgz2cc GW1Cne6oEZg5maUsuSEt8WU= =gB7+ -----END PGP SIGNATURE-----
Dec 09 2005









Dave <Dave_member pathlink.com> 