mirror of
https://github.com/golang/go
synced 2024-11-22 07:44:43 -07:00
parent
52c549fc9b
commit
a074e37489
@ -115,8 +115,8 @@ import (
|
|||||||
// An Int represents a signed multi-precision integer.
|
// An Int represents a signed multi-precision integer.
|
||||||
// The zero value for an Int represents the value 0.
|
// The zero value for an Int represents the value 0.
|
||||||
type Int struct {
|
type Int struct {
|
||||||
i C.mpz_t;
|
i C.mpz_t;
|
||||||
init bool;
|
init bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInt returns a new Int initialized to x.
|
// NewInt returns a new Int initialized to x.
|
||||||
@ -140,7 +140,7 @@ func (z *Int) doinit() {
|
|||||||
|
|
||||||
// Bytes returns z's representation as a big-endian byte array.
|
// Bytes returns z's representation as a big-endian byte array.
|
||||||
func (z *Int) Bytes() []byte {
|
func (z *Int) Bytes() []byte {
|
||||||
b := make([]byte, (z.Len() + 7) / 8);
|
b := make([]byte, (z.Len() + 7)/8);
|
||||||
n := C.size_t(len(b));
|
n := C.size_t(len(b));
|
||||||
C.mpz_export(unsafe.Pointer(&b[0]), &n, 1, 1, 1, 0, &z.i[0]);
|
C.mpz_export(unsafe.Pointer(&b[0]), &n, 1, 1, 1, 0, &z.i[0]);
|
||||||
return b[0:n];
|
return b[0:n];
|
||||||
|
@ -44,12 +44,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
tmp1 = big.NewInt(0);
|
tmp1 = big.NewInt(0);
|
||||||
tmp2 = big.NewInt(0);
|
tmp2 = big.NewInt(0);
|
||||||
numer = big.NewInt(1);
|
numer = big.NewInt(1);
|
||||||
accum = big.NewInt(0);
|
accum = big.NewInt(0);
|
||||||
denom = big.NewInt(1);
|
denom = big.NewInt(1);
|
||||||
ten = big.NewInt(10);
|
ten = big.NewInt(10);
|
||||||
)
|
)
|
||||||
|
|
||||||
func extractDigit() int64 {
|
func extractDigit() int64 {
|
||||||
@ -90,7 +90,7 @@ func main() {
|
|||||||
d = extractDigit();
|
d = extractDigit();
|
||||||
}
|
}
|
||||||
eliminateDigit(d);
|
eliminateDigit(d);
|
||||||
fmt.Printf("%c", d + '0');
|
fmt.Printf("%c", d+'0');
|
||||||
|
|
||||||
if i++; i%50 == 0 {
|
if i++; i%50 == 0 {
|
||||||
fmt.Printf("\n");
|
fmt.Printf("\n");
|
||||||
|
@ -40,4 +40,3 @@ func Puts(s string) {
|
|||||||
C.free(unsafe.Pointer(p));
|
C.free(unsafe.Pointer(p));
|
||||||
C.fflushstdout();
|
C.fflushstdout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ package main
|
|||||||
import "stdio"
|
import "stdio"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// stdio.Stdout.WriteString("hello, world\n");
|
// stdio.Stdout.WriteString("hello, world\n");
|
||||||
stdio.Puts("hello, world");
|
stdio.Puts("hello, world");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user