summaryrefslogtreecommitdiff
path: root/libgo/go/math/big/int.go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-12-22 01:15:33 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-12-22 01:15:33 +0000
commit409a5e7eb4cca107037fafa4a7eea92603edb83d (patch)
tree06f36bbef6fae78278f799194ad0df8ba2dabaa1 /libgo/go/math/big/int.go
parent7e9268b4cf01ab87d9b602f592ed2e2facfadda9 (diff)
downloadgcc-409a5e7eb4cca107037fafa4a7eea92603edb83d.tar.gz
libgo: Update to revision 15193:6fdc1974457c of master library.
From-SVN: r194692
Diffstat (limited to 'libgo/go/math/big/int.go')
-rw-r--r--libgo/go/math/big/int.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/libgo/go/math/big/int.go b/libgo/go/math/big/int.go
index 95c0d58ee97..63a4536e2a0 100644
--- a/libgo/go/math/big/int.go
+++ b/libgo/go/math/big/int.go
@@ -51,6 +51,13 @@ func (z *Int) SetInt64(x int64) *Int {
return z
}
+// SetUint64 sets z to x and returns z.
+func (z *Int) SetUint64(x uint64) *Int {
+ z.abs = z.abs.setUint64(uint64(x))
+ z.neg = false
+ return z
+}
+
// NewInt allocates and returns a new Int set to x.
func NewInt(x int64) *Int {
return new(Int).SetInt64(x)
@@ -519,6 +526,19 @@ func (x *Int) Int64() int64 {
return v
}
+// Uint64 returns the int64 representation of x.
+// If x cannot be represented in an uint64, the result is undefined.
+func (x *Int) Uint64() uint64 {
+ if len(x.abs) == 0 {
+ return 0
+ }
+ v := uint64(x.abs[0])
+ if _W == 32 && len(x.abs) > 1 {
+ v |= uint64(x.abs[1]) << 32
+ }
+ return v
+}
+
// SetString sets z to the value of s, interpreted in the given base,
// and returns z and a boolean indicating success. If SetString fails,
// the value of z is undefined but the returned value is nil.