mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
math/big: fix silly bug in Int64 accessor
Change-Id: If335d45ea1ab6c8aeeb47515f97680e2c1d651f3 Reviewed-on: https://go-review.googlesource.com/7522 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
3eb84c8908
commit
f6580319e4
2 changed files with 3 additions and 1 deletions
|
|
@ -835,7 +835,7 @@ func (x *Float) Int64() (int64, Accuracy) {
|
||||||
if x.neg {
|
if x.neg {
|
||||||
i = -i
|
i = -i
|
||||||
}
|
}
|
||||||
if x.MinPrec() <= 63 {
|
if x.MinPrec() <= uint(x.exp) {
|
||||||
return i, Exact
|
return i, Exact
|
||||||
}
|
}
|
||||||
return i, acc // x truncated
|
return i, acc // x truncated
|
||||||
|
|
|
||||||
|
|
@ -808,12 +808,14 @@ func TestFloatInt64(t *testing.T) {
|
||||||
{"-12345.000000000000000000001", -12345, Above},
|
{"-12345.000000000000000000001", -12345, Above},
|
||||||
{"-12345.0", -12345, Exact},
|
{"-12345.0", -12345, Exact},
|
||||||
{"-1.000000000000000000001", -1, Above},
|
{"-1.000000000000000000001", -1, Above},
|
||||||
|
{"-1.5", -1, Above},
|
||||||
{"-1", -1, Exact},
|
{"-1", -1, Exact},
|
||||||
{"-1e-1000", 0, Above},
|
{"-1e-1000", 0, Above},
|
||||||
{"0", 0, Exact},
|
{"0", 0, Exact},
|
||||||
{"1e-1000", 0, Below},
|
{"1e-1000", 0, Below},
|
||||||
{"1", 1, Exact},
|
{"1", 1, Exact},
|
||||||
{"1.000000000000000000001", 1, Below},
|
{"1.000000000000000000001", 1, Below},
|
||||||
|
{"1.5", 1, Below},
|
||||||
{"12345.0", 12345, Exact},
|
{"12345.0", 12345, Exact},
|
||||||
{"12345.000000000000000000001", 12345, Below},
|
{"12345.000000000000000000001", 12345, Below},
|
||||||
{"9223372036854775807", 9223372036854775807, Exact},
|
{"9223372036854775807", 9223372036854775807, Exact},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue