Commit 92cdde01 authored by Robert Griesemer's avatar Robert Griesemer

go/constant: use new math/big.IsInt and isUint predicates

Slightly cleaner and more readable code.

Change-Id: I35263dbf338861b0a1bd62d59417b6a2c6a4e670
Reviewed-on: https://go-review.googlesource.com/36562
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: default avatarAlan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent ee7fdc26
......@@ -205,13 +205,8 @@ func rtof(x ratVal) floatVal {
func vtoc(x Value) complexVal { return complexVal{x, int64Val(0)} }
var (
minInt64 = big.NewInt(-1 << 63)
maxInt64 = big.NewInt(1<<63 - 1)
)
func makeInt(x *big.Int) Value {
if minInt64.Cmp(x) <= 0 && x.Cmp(maxInt64) <= 0 {
if x.IsInt64() {
return int64Val(x.Int64())
}
return intVal{x}
......@@ -413,7 +408,7 @@ func Uint64Val(x Value) (uint64, bool) {
case int64Val:
return uint64(x), x >= 0
case intVal:
return x.val.Uint64(), x.val.Sign() >= 0 && x.val.BitLen() <= 64
return x.val.Uint64(), x.val.IsUint64()
case unknownVal:
return 0, false
default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment