// String returns the decimal representation of z. func (z *Int) String() string { if z == nil { return "nil" } z.doinit() p := C.mpz_get_str(nil, 10, &z.i[0]) s := C.GoString(p) C.free(unsafe.Pointer(p)) return s }
// string returns z in the base given func (z *Int) string(base int) string { if z == nil { return "<nil>" } z.doinit() p := C.mpz_get_str(nil, C.int(base), &z.i[0]) s := C.GoString(p) C.free(unsafe.Pointer(p)) return s }
func (z *Int) StringBase(base int) (string, error) { if z == nil { return "nil", nil } if base < 2 || base > 36 { return "", os.ErrInvalid } z.doinit() p := C.mpz_get_str(nil, C.int(base), &z.i[0]) s := C.GoString(p) C.free(unsafe.Pointer(p)) return s, nil }