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

Delta Between Two Patch Sets: src/pkg/strconv/ftoa_test.go

Issue 5502079: code review 5502079: strconv: faster FormatFloat(x, *, -1, 64) using Grisu3 ... (Closed)
Left Patch Set: diff -r c956aa39a269 https://go.googlecode.com/hg/ Created 13 years, 3 months ago
Right Patch Set: diff -r 11bb73c84e6c https://go.googlecode.com/hg/ Created 13 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/strconv/ftoa.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package strconv_test 5 package strconv_test
6 6
7 import ( 7 import (
8 "math" 8 "math"
9 "math/rand" 9 "math/rand"
10 . "strconv" 10 . "strconv"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 {0.05, 'f', 1, "0.1"}, 117 {0.05, 'f', 1, "0.1"},
118 {0.05, 'f', 0, "0"}, 118 {0.05, 'f', 0, "0"},
119 {0.5, 'f', 1, "0.5"}, 119 {0.5, 'f', 1, "0.5"},
120 {0.5, 'f', 0, "0"}, 120 {0.5, 'f', 0, "0"},
121 {1.5, 'f', 0, "2"}, 121 {1.5, 'f', 0, "2"},
122 122
123 // http://www.exploringbinary.com/java-hangs-when-converting-2-225073858 5072012e-308/ 123 // http://www.exploringbinary.com/java-hangs-when-converting-2-225073858 5072012e-308/
124 {2.2250738585072012e-308, 'g', -1, "2.2250738585072014e-308"}, 124 {2.2250738585072012e-308, 'g', -1, "2.2250738585072014e-308"},
125 // http://www.exploringbinary.com/php-hangs-on-numeric-value-2-225073858 5072011e-308/ 125 // http://www.exploringbinary.com/php-hangs-on-numeric-value-2-225073858 5072011e-308/
126 {2.2250738585072011e-308, 'g', -1, "2.225073858507201e-308"}, 126 {2.2250738585072011e-308, 'g', -1, "2.225073858507201e-308"},
127
128 // Issue 2625.
129 {383260575764816448, 'f', 0, "383260575764816448"},
130 {383260575764816448, 'g', -1, "3.8326057576481645e+17"},
127 } 131 }
128 132
129 func TestFtoa(t *testing.T) { 133 func TestFtoa(t *testing.T) {
130 for i := 0; i < len(ftoatests); i++ { 134 for i := 0; i < len(ftoatests); i++ {
131 test := &ftoatests[i] 135 test := &ftoatests[i]
132 s := FormatFloat(test.f, test.fmt, test.prec, 64) 136 s := FormatFloat(test.f, test.fmt, test.prec, 64)
133 if s != test.s { 137 if s != test.s {
134 t.Error("testN=64", test.f, string(test.fmt), test.prec, "want", test.s, "got", s) 138 t.Error("testN=64", test.f, string(test.fmt), test.prec, "want", test.s, "got", s)
135 } 139 }
136 x := AppendFloat([]byte("abc"), test.f, test.fmt, test.prec, 64) 140 x := AppendFloat([]byte("abc"), test.f, test.fmt, test.prec, 64)
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 AppendFloat(dst, -5.11e-95, 'g', -1, 64) 247 AppendFloat(dst, -5.11e-95, 'g', -1, 64)
244 } 248 }
245 } 249 }
246 250
247 func BenchmarkAppendFloatBig(b *testing.B) { 251 func BenchmarkAppendFloatBig(b *testing.B) {
248 dst := make([]byte, 0, 30) 252 dst := make([]byte, 0, 30)
249 for i := 0; i < b.N; i++ { 253 for i := 0; i < b.N; i++ {
250 AppendFloat(dst, 123456789123456789123456789, 'g', -1, 64) 254 AppendFloat(dst, 123456789123456789123456789, 'g', -1, 64)
251 } 255 }
252 } 256 }
LEFTRIGHT

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