Skip to content

math: Calls to math.Sin and math.Cos with values > 1e17 return values outside of [-1,1]  #8526

@gopherbot

Description

@gopherbot

by juanval:

go version go1.3 darwin/amd64

What steps reproduce the problem?
Example: http://play.golang.org/p/-GqZSloAM3

    1. fmt.Println(math.Sin(1.5e17))

What happened?

    Program prints "1.231298118089368e+08"

What should have happened instead?

    Program should print value in [-1,1] range

Please provide any additional information below.

    Source code for math.Sin warns that "Results may be meaningless for x > 2**49 = 5.6e14". However, it says nothing about not respecting the [-1,1] range. 

    I discovered this when doing math.Sin(float64(time.Now().UnixNano())) returned 1.1828933275348654e+20

    Also, that information does not appear in godoc.

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