-
Notifications
You must be signed in to change notification settings - Fork 8
Add non-scientific serialization for float64 #1
base: master
Are you sure you want to change the base?
Conversation
…tion Functionality corresponding to calling strconv.AppendFloat(buf, value, 'f', -1, 64). $ go test -run=^$ -bench=. goos: linux goarch: amd64 pkg: github.com/cespare/ryu BenchmarkFormatFloat32-2 2649049 428 ns/op BenchmarkStrconvFormatFloat32-2 1557508 764 ns/op BenchmarkFormatFloat64-2 2822534 420 ns/op BenchmarkStrconvFormatFloat64-2 1525341 777 ns/op BenchmarkAppendFloat32/0e+00-2 25680454 41.5 ns/op BenchmarkAppendFloat32/1e+00-2 7266823 165 ns/op BenchmarkAppendFloat32/3e-01-2 3616010 314 ns/op BenchmarkAppendFloat32/3e-10-2 3842422 326 ns/op BenchmarkAppendFloat32/1e+06-2 5579458 201 ns/op BenchmarkAppendFloat32/-1.2345e+02-2 4433781 270 ns/op BenchmarkAppendFloat32/-1.2345679e+08-2 3892467 287 ns/op BenchmarkStrconvAppendFloat32/0e+00-2 6826143 175 ns/op BenchmarkStrconvAppendFloat32/1e+00-2 5573404 215 ns/op BenchmarkStrconvAppendFloat32/3e-01-2 4037379 291 ns/op BenchmarkStrconvAppendFloat32/3e-10-2 3903271 331 ns/op BenchmarkStrconvAppendFloat32/1e+06-2 3436240 330 ns/op BenchmarkStrconvAppendFloat32/-1.2345e+02-2 2763634 425 ns/op BenchmarkStrconvAppendFloat32/-1.2345679e+08-2 2920750 416 ns/op BenchmarkAppendFloat64/0e+00-2 27900621 41.0 ns/op BenchmarkAppendFloat64/1e+00-2 8091024 124 ns/op BenchmarkAppendFloat64/3e-01-2 4379684 273 ns/op BenchmarkAppendFloat64/3e-10-2 4232997 270 ns/op BenchmarkAppendFloat64/1e+06-2 7254286 163 ns/op BenchmarkAppendFloat64/-1.2345e+02-2 4217469 275 ns/op BenchmarkAppendFloat64/-1.2345678912345679e+08-2 3618212 321 ns/op BenchmarkAppendFloat64/6.226662346353213e-309-2 4073581 285 ns/op BenchmarkStrconvAppendFloat64/0e+00-2 6224215 186 ns/op BenchmarkStrconvAppendFloat64/1e+00-2 5264420 228 ns/op BenchmarkStrconvAppendFloat64/3e-01-2 3811977 307 ns/op BenchmarkStrconvAppendFloat64/3e-10-2 3781111 306 ns/op BenchmarkStrconvAppendFloat64/1e+06-2 3492462 334 ns/op BenchmarkStrconvAppendFloat64/-1.2345e+02-2 2677958 436 ns/op BenchmarkStrconvAppendFloat64/-1.2345678912345679e+08-2 2311795 493 ns/op BenchmarkStrconvAppendFloat64/6.226662346353213e-309-2 6206 161431 ns/op BenchmarkStrconvAppendFloat64f/0e+00-2 6988803 163 ns/op BenchmarkStrconvAppendFloat64f/1e+00-2 4637444 253 ns/op BenchmarkStrconvAppendFloat64f/3e-01-2 3152067 424 ns/op BenchmarkStrconvAppendFloat64f/3e-10-2 2588025 448 ns/op BenchmarkStrconvAppendFloat64f/1e+06-2 2818968 391 ns/op BenchmarkStrconvAppendFloat64f/-1.2345e+02-2 2591952 462 ns/op BenchmarkStrconvAppendFloat64f/-1.2345678912345679e+08-2 2122593 547 ns/op BenchmarkStrconvAppendFloat64f/6.226662346353213e-309-2 6163 170631 ns/op BenchmarkAppendFloat64f/0e+00-2 25743180 40.5 ns/op BenchmarkAppendFloat64f/1e+00-2 10366732 105 ns/op BenchmarkAppendFloat64f/3e-01-2 4462056 258 ns/op BenchmarkAppendFloat64f/3e-10-2 3706179 324 ns/op BenchmarkAppendFloat64f/1e+06-2 6285136 184 ns/op BenchmarkAppendFloat64f/-1.2345e+02-2 4257297 294 ns/op BenchmarkAppendFloat64f/-1.2345678912345679e+08-2 3561897 312 ns/op BenchmarkAppendFloat64f/6.226662346353213e-309-2 540076 2318 ns/op
Thanks for the Go port of this algo! Seems like the effort to get parts of it into the stdlib has stalled a bit unfortunately. |
Sorry, but it's hard for me to make time to review this since it's fairly low priority. (See my note about adding features in the README.)
Can you explain more about this? JSON includes scientific notation.
I handed off the effort to Rémy Oudompheng earlier this year. However, there has been recent activity and I'm hopeful that it will be merged in time for Go 1.15. Follow https://golang.org/cl/170078 if you're interested. |
Yeah, I saw you're note on the project status in the README but figured that this was an isolated enough addition that it would be fairly low effort to bring it in. Feel free to close the PR if you don't want it merged however. I've sourced/vendored the code I need already. I just figured it would be nice to upstream it.
I honestly cannot find were I picked that up, I agree it seems wrong. Please ignore the statement.
Yeah, let's hope. There are three distinct CLs that require someone from the core time to find time reviewing them. |
Added functionality for outputting result in non-scientific format for float64. This is useful in JSON serialization for example where correct handling of scientific format cannot be assumed.