Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math: Ldexp doesn't handle denormals correctly #23407

Closed
crvv opened this issue Jan 11, 2018 · 2 comments
Closed

math: Ldexp doesn't handle denormals correctly #23407

crvv opened this issue Jan 11, 2018 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@crvv
Copy link
Contributor

crvv commented Jan 11, 2018

What version of Go are you using (go version)?

1.9.2 and tip

Does this issue reproduce with the latest release?

Yes

What did you do?

https://play.golang.org/p/3OfmZgFcjRR

What did you expect to see?

math.Ldexp(1, -1075) = 0
math.Ldexp(1.000000000000001, -1075) = 5e-324
math.Ldexp(2, -1075) = 5e-324

What did you see instead?

math.Ldexp(1, -1075) = 0
math.Ldexp(1.000000000000001, -1075) = 0
math.Ldexp(2, -1075) = 5e-324

The result of ldexp_386.s is correct.
This issue is that the function ldexp written in Go doesn't handle denormals correctly.

@gopherbot
Copy link

Change https://golang.org/cl/87338 mentions this issue: math: fix Ldexp when result is below 5e-324

@odeke-em
Copy link
Member

/cc @griesemer @ALTree @ericlagergren

@ALTree ALTree added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 11, 2018
@ALTree ALTree added this to the Go1.11 milestone Mar 11, 2018
dmitshur added a commit to gopherjs/gopherjs that referenced this issue Jun 29, 2018
In Go 1.11, there has been an improvement made to Ldexp for some
extreme values. The previous Math.pow-using algorithm doesn't produce
correct results. Use the Go implementation of ldexp for those values.

Continue to use the current Math.pow approach for other inputs because
it's much faster:

	$ gopherjs test -v --run=none --bench=Ldexp math
	BenchmarkLdexp 	2000000000	         0.44 ns/op

Compared to using the Go implementation for all inputs, without the
Math.pow fast path:

	$ gopherjs test -v --run=none --bench=Ldexp math
	BenchmarkLdexp 	 5000000	       203 ns/op

Follows golang/go@4b265fb.
Updates golang/go#23407.
dmitshur added a commit to gopherjs/gopherjs that referenced this issue Jun 29, 2018
In Go 1.11, there has been an improvement made to Ldexp for some
extreme values. The previous Math.pow-using algorithm doesn't produce
correct results. Use the Go implementation of ldexp for those values.

Continue to use the current Math.pow approach for other inputs because
it's much faster:

	$ gopherjs test -v --run=none --bench=Ldexp math
	BenchmarkLdexp 	2000000000	         0.44 ns/op

Compared to using the Go implementation for all inputs, without the
Math.pow fast path:

	$ gopherjs test -v --run=none --bench=Ldexp math
	BenchmarkLdexp 	 5000000	       203 ns/op

Follows golang/go@4b265fb.
Updates golang/go#23407.
dmitshur added a commit to gopherjs/gopherjs that referenced this issue Jun 29, 2018
In Go 1.11, there has been an improvement made to Ldexp for some
extreme values. The previous Math.pow-using algorithm doesn't produce
correct results. Use the Go implementation of ldexp for those values.

Continue to use the current Math.pow approach for other inputs because
it's much faster:

	$ gopherjs test -v --run=none --bench=Ldexp math
	BenchmarkLdexp 	2000000000	         0.44 ns/op

Compared to using the Go implementation for all inputs, without the
Math.pow fast path:

	$ gopherjs test -v --run=none --bench=Ldexp math
	BenchmarkLdexp 	 5000000	       203 ns/op

Follows golang/go@4b265fb.
Updates golang/go#23407.
dmitshur added a commit to gopherjs/gopherjs that referenced this issue Aug 21, 2018
In Go 1.11, there has been an improvement made to Ldexp for some
extreme values. The previous Math.pow-using algorithm doesn't produce
correct results. Use the Go implementation of ldexp for those values.

Continue to use the current Math.pow approach for other inputs because
it's much faster:

	$ gopherjs test -v --run=none --bench=Ldexp math
	BenchmarkLdexp 	2000000000	         0.44 ns/op

Compared to using the Go implementation for all inputs, without the
Math.pow fast path:

	$ gopherjs test -v --run=none --bench=Ldexp math
	BenchmarkLdexp 	 5000000	       203 ns/op

Follows golang/go@4b265fb.
Updates golang/go#23407.
@golang golang locked and limited conversation to collaborators Mar 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants