$16 GRAYBYTE WORDPRESS FILE MANAGER $60

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/usr/lib/golang/src/math/big/

HOME
Current File : /usr/lib/golang/src/math/big//intmarsh.go
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// This file implements encoding/decoding of Ints.

package big

import (
	"bytes"
	"fmt"
)

// Gob codec version. Permits backward-compatible changes to the encoding.
const intGobVersion byte = 1

// GobEncode implements the [encoding/gob.GobEncoder] interface.
func (x *Int) GobEncode() ([]byte, error) {
	if x == nil {
		return nil, nil
	}
	buf := make([]byte, 1+len(x.abs)*_S) // extra byte for version and sign bit
	i := x.abs.bytes(buf) - 1            // i >= 0
	b := intGobVersion << 1              // make space for sign bit
	if x.neg {
		b |= 1
	}
	buf[i] = b
	return buf[i:], nil
}

// GobDecode implements the [encoding/gob.GobDecoder] interface.
func (z *Int) GobDecode(buf []byte) error {
	if len(buf) == 0 {
		// Other side sent a nil or default value.
		*z = Int{}
		return nil
	}
	b := buf[0]
	if b>>1 != intGobVersion {
		return fmt.Errorf("Int.GobDecode: encoding version %d not supported", b>>1)
	}
	z.neg = b&1 != 0
	z.abs = z.abs.setBytes(buf[1:])
	return nil
}

// AppendText implements the [encoding.TextAppender] interface.
func (x *Int) AppendText(b []byte) (text []byte, err error) {
	return x.Append(b, 10), nil
}

// MarshalText implements the [encoding.TextMarshaler] interface.
func (x *Int) MarshalText() (text []byte, err error) {
	return x.AppendText(nil)
}

// UnmarshalText implements the [encoding.TextUnmarshaler] interface.
func (z *Int) UnmarshalText(text []byte) error {
	if _, ok := z.setFromScanner(bytes.NewReader(text), 0); !ok {
		return fmt.Errorf("math/big: cannot unmarshal %q into a *big.Int", text)
	}
	return nil
}

// The JSON marshalers are only here for API backward compatibility
// (programs that explicitly look for these two methods). JSON works
// fine with the TextMarshaler only.

// MarshalJSON implements the [encoding/json.Marshaler] interface.
func (x *Int) MarshalJSON() ([]byte, error) {
	if x == nil {
		return []byte("null"), nil
	}
	return x.abs.itoa(x.neg, 10), nil
}

// UnmarshalJSON implements the [encoding/json.Unmarshaler] interface.
func (z *Int) UnmarshalJSON(text []byte) error {
	// Ignore null, like in the main JSON package.
	if string(text) == "null" {
		return nil
	}
	return z.UnmarshalText(text)
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
16 Dec 2025 9.30 PM
root / root
0755
internal
--
16 Dec 2025 9.30 PM
root / root
0755
accuracy_string.go
0.632 KB
4 Dec 2025 6.06 PM
root / root
0644
arith.go
8.604 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_386.s
4.864 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_amd64.go
0.267 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_amd64.s
8.676 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_arm.s
6.373 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_arm64.s
6.475 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_decl.go
2.457 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_decl_pure.go
0.638 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_loong64.s
9.312 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_mips64x.s
9.205 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_mipsx.s
9.039 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_ppc64x.s
6.672 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_riscv64.s
9.027 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_s390x.s
7.847 KB
4 Dec 2025 6.06 PM
root / root
0644
arith_wasm.s
0.507 KB
4 Dec 2025 6.06 PM
root / root
0644
arithvec_s390x.go
0.325 KB
4 Dec 2025 6.06 PM
root / root
0644
arithvec_s390x.s
8.676 KB
4 Dec 2025 6.06 PM
root / root
0644
calibrate.md
10.205 KB
4 Dec 2025 6.06 PM
root / root
0644
calibrate_graph.go
9.278 KB
4 Dec 2025 6.06 PM
root / root
0644
decimal.go
6.635 KB
4 Dec 2025 6.06 PM
root / root
0644
doc.go
3.804 KB
4 Dec 2025 6.06 PM
root / root
0644
float.go
44.528 KB
4 Dec 2025 6.06 PM
root / root
0644
floatconv.go
8.349 KB
4 Dec 2025 6.06 PM
root / root
0644
floatmarsh.go
3.882 KB
4 Dec 2025 6.06 PM
root / root
0644
ftoa.go
13.496 KB
4 Dec 2025 6.06 PM
root / root
0644
int.go
33.54 KB
4 Dec 2025 6.06 PM
root / root
0644
intconv.go
6.695 KB
4 Dec 2025 6.06 PM
root / root
0644
intmarsh.go
2.29 KB
4 Dec 2025 6.06 PM
root / root
0644
nat.go
24.725 KB
4 Dec 2025 6.06 PM
root / root
0644
natconv.go
15.596 KB
4 Dec 2025 6.06 PM
root / root
0644
natdiv.go
34.313 KB
4 Dec 2025 6.06 PM
root / root
0644
natmul.go
8.409 KB
4 Dec 2025 6.06 PM
root / root
0644
prime.go
10.536 KB
4 Dec 2025 6.06 PM
root / root
0644
rat.go
13.946 KB
4 Dec 2025 6.06 PM
root / root
0644
ratconv.go
12.634 KB
4 Dec 2025 6.06 PM
root / root
0644
ratmarsh.go
2.371 KB
4 Dec 2025 6.06 PM
root / root
0644
roundingmode_string.go
0.8 KB
4 Dec 2025 6.06 PM
root / root
0644
sqrt.go
2.793 KB
4 Dec 2025 6.06 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF