[Issue 11409] Array element-wise comparison
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 1 03:44:41 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11409
--- Comment #2 from daniel350 at bigpond.com 2013-11-01 03:44:39 PDT ---
(In reply to comment #1)
> 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.
Why would I want to compare a sorted array?
I want to compare two different arrays?
I see no reason why a built-in comparison would assume the array would be
sorted?
This is working as it is implemented, but I wouldn't say it is working as
expected. Not by a long shot.
Is there any reference for this behaviour?
--
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