www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Large integer division

reply Deewiant <deewiant.doesnotlike.spam gmail.com> writes:
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
next sibling parent reply "Kris" <fu bar.com> writes:
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
parent Dave <Dave_member pathlink.com> writes:
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
prev sibling next sibling parent reply =?ISO-8859-15?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
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
parent =?ISO-8859-15?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
 prints:
 10
 42
<duh> -42 --anders
Dec 07 2005
prev sibling next sibling parent "Walter Bright" <newshound digitalmars.com> writes:
"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
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----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