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 (
	
	
)
Gob codec version. Permits backward-compatible changes to the encoding.
const intGobVersion byte = 1
GobEncode implements the gob.GobEncoder interface.
func ( *Int) () ([]byte, error) {
	if  == nil {
		return nil, nil
	}
	 := make([]byte, 1+len(.abs)*_S) // extra byte for version and sign bit
	 := .abs.bytes() - 1            // i >= 0
	 := intGobVersion << 1              // make space for sign bit
	if .neg {
		 |= 1
	}
	[] = 
	return [:], nil
}
GobDecode implements the gob.GobDecoder interface.
func ( *Int) ( []byte) error {
Other side sent a nil or default value.
		* = Int{}
		return nil
	}
	 := [0]
	if >>1 != intGobVersion {
		return fmt.Errorf("Int.GobDecode: encoding version %d not supported", >>1)
	}
	.neg = &1 != 0
	.abs = .abs.setBytes([1:])
	return nil
}
MarshalText implements the encoding.TextMarshaler interface.
func ( *Int) () ( []byte,  error) {
	if  == nil {
		return []byte("<nil>"), nil
	}
	return .abs.itoa(.neg, 10), nil
}
UnmarshalText implements the encoding.TextUnmarshaler interface.
func ( *Int) ( []byte) error {
	if ,  := .setFromScanner(bytes.NewReader(), 0); ! {
		return fmt.Errorf("math/big: cannot unmarshal %q into a *big.Int", )
	}
	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 json.Marshaler interface.
func ( *Int) () ([]byte, error) {
	return .MarshalText()
}
UnmarshalJSON implements the json.Unmarshaler interface.
Ignore null, like in the main JSON package.
	if string() == "null" {
		return nil
	}
	return .UnmarshalText()