| Thread overview | |||||
|---|---|---|---|---|---|
  | 
January 13, 2007 Question about Phobos library file ("ti_uint.d") | ||||
|---|---|---|---|---|
  | ||||
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")?  | ||||
January 13, 2007 Re: Question about Phobos library file ("ti_uint.d") | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Marcio Faustino  | 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;
> }
<snip>
Because that would screw up if the difference between the two uints is greater than 2147483647.
Stewart.
 | |||
January 13, 2007 Re: Question about Phobos library file ("ti_uint.d") | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Stewart Gordon  | 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.
 | |||
Copyright © 1999-2021 by the D Language Foundation
 
Permalink
Reply