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

Issue 100580044: code review 100580044: cmd/gc: fix float32 const conversion and printing of bi... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 10 months ago by rsc
Modified:
10 years, 7 months ago
Reviewers:
rsc, iant
CC:
golang-codereviews, iant, r
Visibility:
Public.

Description

cmd/gc: fix float32 const conversion and printing of big float consts The float32 const conversion used to round to float64 and then use the hardware to round to float32. Even though there was a range check before this conversion, the double rounding introduced inaccuracy: the round to float64 might round the value further away from the float32 range, reaching a float64 value that could not actually be rounded to float32. The hardware appears to give us 0 in that case, but it is probably undefined. Double rounding also meant that the wrong value might be used for certain border cases. Do the rounding the float32 ourselves, just as we already did the rounding to float64. This makes the conversion precise and also makes the conversion match the range check. Finally, add some code to print very large (bigger than float64) floating point constants in decimal floating point notation instead of falling back to the precise but human-unreadable binary floating point notation. Fixes issue 8015.

Patch Set 1 #

Patch Set 2 : diff -r d419520d0d2e https://code.google.com/p/go/ #

Patch Set 3 : diff -r d419520d0d2e https://code.google.com/p/go/ #

Patch Set 4 : diff -r 793272b5aeef https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+128 lines, -26 lines) Patch
M src/cmd/gc/const.c View 1 3 chunks +8 lines, -7 lines 0 comments Download
M src/cmd/gc/go.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/gc/mparith1.c View 1 1 chunk +25 lines, -5 lines 0 comments Download
M src/cmd/gc/mparith3.c View 1 4 chunks +23 lines, -14 lines 0 comments Download
A test/float_lit2.go View 1 1 chunk +43 lines, -0 lines 0 comments Download
A test/float_lit3.go View 1 2 1 chunk +28 lines, -0 lines 0 comments Download

Messages

Total messages: 6
rsc
Hello golang-codereviews@googlegroups.com (cc: iant, r), I'd like you to review this change to https://code.google.com/p/go/
10 years, 10 months ago (2014-05-20 00:35:10 UTC) #1
iant
LGTM Your tests pass with gccgo modolu error message syntax, which is encouraging.
10 years, 10 months ago (2014-05-20 01:03:28 UTC) #2
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=5b9ac653acf6 *** cmd/gc: fix float32 const conversion and printing of big float ...
10 years, 10 months ago (2014-05-20 02:58:01 UTC) #3
gobot
This CL appears to have broken the freebsd-386 builder. See http://build.golang.org/log/3c79e2466c4282e725d8aa0cd2efce7234ba8fed
10 years, 10 months ago (2014-05-20 03:06:15 UTC) #4
lucio
It seems new arguments were added to the print invocation in cmd/gc/mparith1.c:594 without adding corresponding ...
10 years, 7 months ago (2014-08-07 10:59:19 UTC) #5
rsc
10 years, 7 months ago (2014-08-07 12:07:30 UTC) #6
Sign in to reply to this message.

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