Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(5115)

Issue 4805051: code review 4805051: sort: fixed bug in (Float64Slice) Less; NaN less than a...

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 9 months ago by Florian Uekermann
Modified:
12 years, 9 months ago
Reviewers:
rsc
CC:
golang-dev, r2, rsc, r
Visibility:
Public.

Description

sort: fixed bug in (Float64Slice) Less; NaN less than anything else Previously comparisons with NaN led to contradictory results if it was compared to anything not NaN, since Less always returned false, thus breaking monotonicity of ordering. This fix makes NaN less than anything else and adds NaN and (+-)Inf to testcases. Fixes issue 2092.

Patch Set 1 #

Patch Set 2 : diff -r e6713d09fa34 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r e6713d09fa34 https://go.googlecode.com/hg/ #

Total comments: 2

Patch Set 4 : diff -r 1a4e153f70fd https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+5 lines, -2 lines) Patch
M src/pkg/sort/sort.go View 1 2 3 2 chunks +3 lines, -1 line 0 comments Download
M src/pkg/sort/sort_test.go View 1 2 3 2 chunks +2 lines, -1 line 0 comments Download

Messages

Total messages: 23
Florian Uekermann
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
12 years, 9 months ago (2011-07-22 21:43:19 UTC) #1
Florian Uekermann
For some reason gotest now fails to start the tests for the sort package with ...
12 years, 9 months ago (2011-07-22 22:34:51 UTC) #2
r2
you've added a dependency, which means the problem is likely that you've created a dependency ...
12 years, 9 months ago (2011-07-22 22:42:23 UTC) #3
rsc
This is a real, preexisting cycle. You're just hitting now because the runtime doesn't catch ...
12 years, 9 months ago (2011-07-23 00:43:54 UTC) #4
Florian Uekermann
Ah I see... ...wrong packagename + no init/missing check. After pulling the changes everything works ...
12 years, 9 months ago (2011-07-23 01:35:37 UTC) #5
r
http://codereview.appspot.com/4805051/diff/3001/src/pkg/sort/sort.go File src/pkg/sort/sort.go (right): http://codereview.appspot.com/4805051/diff/3001/src/pkg/sort/sort.go#newcode9 src/pkg/sort/sort.go:9: import "math" dependency cycles aside, it's kind of a ...
12 years, 9 months ago (2011-07-23 01:41:42 UTC) #6
rsc
> dependency cycles aside, it's kind of a shame to add an import to a ...
12 years, 9 months ago (2011-07-23 01:49:52 UTC) #7
r2
i give up. leaving for rsc. -rob
12 years, 9 months ago (2011-07-23 01:57:43 UTC) #8
Florian Uekermann
http://codereview.appspot.com/4805051/diff/3001/src/pkg/sort/sort.go File src/pkg/sort/sort.go (right): http://codereview.appspot.com/4805051/diff/3001/src/pkg/sort/sort.go#newcode9 src/pkg/sort/sort.go:9: import "math" the current logic is better : 1 ...
12 years, 9 months ago (2011-07-23 02:22:34 UTC) #9
r2
maybe not. isn't it worth doing the other comparison (b < a after a < ...
12 years, 9 months ago (2011-07-23 02:22:48 UTC) #10
rsc
what about a < b || !(b >= a) with a good comment? that's worst ...
12 years, 9 months ago (2011-07-23 02:28:00 UTC) #11
Florian Uekermann
its not much of a function its just a!=a, thats it, just one comparison
12 years, 9 months ago (2011-07-23 02:28:07 UTC) #12
r2
On 23/07/2011, at 12:27 PM, Russ Cox wrote: > what about > > a < ...
12 years, 9 months ago (2011-07-23 02:30:19 UTC) #13
Florian Uekermann
isn't that true for two NaNs? On 2011/07/23 02:30:19, r2 wrote: > On 23/07/2011, at ...
12 years, 9 months ago (2011-07-23 02:36:39 UTC) #14
r2
On 23/07/2011, at 12:36 PM, f1@uekermann-online.de wrote: > isn't that true for two NaNs? sigh, ...
12 years, 9 months ago (2011-07-23 02:44:55 UTC) #15
Florian Uekermann
So we agree that its wrong for Less? On 2011/07/23 02:44:55, r2 wrote: > On ...
12 years, 9 months ago (2011-07-23 02:50:27 UTC) #16
rsc
On Fri, Jul 22, 2011 at 22:50, <f1@uekermann-online.de> wrote: > So we agree that its ...
12 years, 9 months ago (2011-07-23 02:57:18 UTC) #17
Florian Uekermann
On 2011/07/23 02:57:18, rsc wrote: > On Fri, Jul 22, 2011 at 22:50, <mailto:f1@uekermann-online.de> wrote: ...
12 years, 9 months ago (2011-07-23 03:05:18 UTC) #18
rsc
okay, then i guess the simplest possible is return a < b || math.IsNaN(a) && ...
12 years, 9 months ago (2011-07-23 03:06:34 UTC) #19
Florian Uekermann
On 2011/07/23 03:06:34, rsc wrote: > okay, then i guess the simplest possible is > ...
12 years, 9 months ago (2011-07-23 03:12:27 UTC) #20
Florian Uekermann
Hello golang-dev@googlegroups.com, r@google.com, rsc@golang.org, r@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 9 months ago (2011-07-23 03:24:35 UTC) #21
rsc
LGTM
12 years, 9 months ago (2011-07-23 19:44:42 UTC) #22
rsc
12 years, 9 months ago (2011-07-23 19:47:09 UTC) #23
*** Submitted as http://code.google.com/p/go/source/detail?r=ca14957bb4f3 ***

sort: fixed bug in (Float64Slice) Less; NaN less than anything else

Previously comparisons with NaN led to contradictory results if it was
compared to anything not NaN, since Less always returned false, thus
breaking monotonicity of ordering.
This fix makes NaN less than anything else and adds NaN and (+-)Inf to
testcases.

Fixes issue 2092.

R=golang-dev, r, rsc, r
CC=golang-dev
http://codereview.appspot.com/4805051

Committer: Russ Cox <rsc@golang.org>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b