// Int64 returns the int64 representation of x. // If x cannot be represented in an int64, the result is undefined. func (x *Int) Int64() (y int64) { if !x.init { return } if C.mpz_fits_slong_p(&x.i[0]) != 0 { return int64(C.mpz_get_si(&x.i[0])) } // Undefined result if > 64 bits if x.BitLen() > 64 { return } C.mpz_export(unsafe.Pointer(&y), nil, -1, 8, 0, 0, &x.i[0]) if x.Sign() < 0 { y = -y } return }
func (z *Int) Int64() int64 { if !z.init { return 0 } return int64(C.mpz_get_si(&z.i[0])) }
// Int32 returns the int32 representation of z, if z fits into a signed int32. // If z is too big to fit in a int32 then the result is undefined. // // NB This is not part of big.Int func (z *Int) Int32() int32 { z.doinit() return int32(C.mpz_get_si(&z.i[0])) }
func (z *Int) Sint() int { if !z.init { return 0 } return int(C.mpz_get_si(&z.i[0])) }
// Int64 returns the int64 representation of x. If x cannot be represented // in an int64, the result is undefined. func (z *Int) Int64() int64 { if !z.init { return 0 } return int64(C.mpz_get_si(z.ptr)) }