Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-artie committed Jun 25, 2024
1 parent 04ef697 commit 3848147
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/debezium/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func EncodeDecimal(value string, scale uint16) ([]byte, error) {
return encodeBigInt(bigIntValue), nil
}

// encodeBigInt encodes a [big.Int] into a byte slice using two's complement.
func encodeBigInt(bigIntValue *big.Int) []byte {
data := bigIntValue.Bytes() // [Bytes] returns the absolute value of the number.
if bigIntValue.Sign() < 0 {
Expand Down Expand Up @@ -62,6 +63,7 @@ func encodeBigInt(bigIntValue *big.Int) []byte {
return data
}

// decodeBigInt decodes a [big.Int] from a byte slice that has been encoded using two's complement.
func decodeBigInt(data []byte) *big.Int {
bigInt := new(big.Int)

Expand Down

0 comments on commit 3848147

Please sign in to comment.