[Issue 11409] Array element-wise comparison
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 1 03:32:40 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11409
Iain Buclaw <ibuclaw at ubuntu.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |ibuclaw at ubuntu.com
Resolution| |INVALID
--- Comment #1 from Iain Buclaw <ibuclaw at ubuntu.com> 2013-11-01 03:32:37 PDT ---
Your assumption is not quite right. This is the loop comparisons goes off:
for (size_t u = 0; u < len; u++)
{
int result = s1[u] - s2[u];
if (result)
return result;
}
And in you examples:
---
Code: assert([2, 0, 0] > [1, 1, 1]);
---
Generates: assert(compare(s1, s2) > 0);
---
Returns: result = 2 - 1; => return 1
---
Code: assert([0, 2, 0] < [1, 1, 1]);
---
Generates: assert(compare(s1, s2) < 0);
---
Returns: result = 0 - 1; => return -1;
---
Code: assert([0, 0, 2] < [1, 1, 1]);
---
Generates: assert(compare(s1, s2) < 0);
---
Returns: result = 0 - 1; => return -1;
My advise to you would be to compare a *SORTED* array.
Marking as invalid because this is working as expected.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list