digitalmars.D.learn - Question about Phobos library file ("ti_uint.d")
- Marcio Faustino <m.faustino.remove gmail.com> Jan 13 2007
- Stewart Gordon <smjg_1998 yahoo.com> Jan 13 2007
Hi everyone,
Why does the method compare of the class TypeInfo_k (in file
"src/phobos/std/typeinfo/ti_uint.d") isn't simply:
int compare(void *p1, void *p2) {
return *cast(uint*) p1 - *cast(uint*) p2;
}
as the same method of the class TypeInfo_h (in file
"src/phobos/std/typeinfo/ti_ubyte.d")?
Jan 13 2007
Marcio Faustino wrote:Hi everyone, Why does the method compare of the class TypeInfo_k (in file "src/phobos/std/typeinfo/ti_uint.d") isn't simply: int compare(void *p1, void *p2) { return *cast(uint*) p1 - *cast(uint*) p2; }
Because that would screw up if the difference between the two uints is greater than 2147483647. Stewart.
Jan 13 2007
Stewart Gordon wrote:Because that would screw up if the difference between the two uints is greater than 2147483647. Stewart.
Right, because of the int.max limit. Thanks.
Jan 13 2007








Marcio Faustino <m.faustino.remove-this gmail.com>