storing decimal into pgtype numeric

1.8k Views Asked by At

I was working with pgtype.NumRange. The lower and upper bounds are typed pgtype.Numeric. pgtype.Numeric has the following fields

type Numeric struct {
    Int              *big.Int
    Exp              int32
    Status           Status
    NaN              bool
    InfinityModifier InfinityModifier
}

I guess I'm suppose to able to represent any number using the duo of the Int and Exp fields, but I don't know how to, as big.Int and `int32' are integer types.

From Postgres docs, I can see that numrange can take decimal values in any of lower and upper bounds and data type numeric is a superset of decimal type. So I know I should be able to use decimals, but how can I go about this?

0

There are 0 best solutions below