示例#1
0
文件: argo.go 项目: nuin/ampify
func WriteDecimal(value *big.Decimal, buffer *bytes.Buffer) {
	buffer.WriteByte('\x01')
	left, right := value.Components()
	positive := writeBigInt(left, buffer, bigintMagicNumber1)
	if right != nil {
		if positive {
			buffer.WriteByte('\x00')
		} else {
			buffer.WriteByte('\xff')
		}
		writeBigInt(right, buffer, bigintMagicNumber2)
	}
}
示例#2
0
func EncodeBigDecimal(value *big.Decimal) []byte {
	left, right := value.Components()
	encoding := encodeBigInt(left, bigintMagicNumber1)
	if right != nil {
		if left.IsNegative() {
			encoding = append(encoding, '\xff')
		} else {
			encoding = append(encoding, '\x00')
		}
		encoding = append(encoding, encodeBigInt(right, bigintMagicNumber2)...)
	}
	return encoding
}