Skip to content

math/big: Rat.SetFloat64: Inconsistent between document and actual result #17221

@bupjae

Description

@bupjae

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

go1.7

What operating system and processor architecture are you using (go env)?

windows/amd64

What did you do?

https://play.golang.org/p/kkiH1mxD7F

What did you expect to see?

6/5

The document https://golang.org/pkg/math/big says this:
z2 := new(Rat).SetFloat64(1.2) // z2 := 6/5

What did you see instead?

5404319552844595/4503599627370496

I understand the result of the program, as float64 can't represent 1.2 exactly.
If this is the case, the document should be changed; either mention the actual result with explaination, or select value that float64 can represent exactly.

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