Skip to content

math: Sin returns value not in [-1, 1] for very large values #7110

@gopherbot

Description

@gopherbot

by zhuwl08:

I'm using go version go1.2 darwin/amd64, but the issue still exists in the latest go src.

Here is the demo code:

http://play.golang.org/p/K4Fc8ts24u

{{{
a := 387001390666326231482368.000000
fmt.Printf("Sin(a) = %e\n", math.Sin(a))
}}}

The output is 

{{{
Sin(a) = 6.944847e+296
}}}

I know that for a large float, it's hard to get the accurate value for math.Sin, but I
expected that the return value should be in range [-1, 1], at least, which I rely on to
produce a reasonable value for other input.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions