将小数存储到 pgtype numeric 中
我正在使用 pgtype.NumRange 。下限和上限的类型为 pgtype.Numeric
。 pgtype.Numeric 有以下字段
type Numeric struct {
Int *big.Int
Exp int32
Status Status
NaN bool
InfinityModifier InfinityModifier
}
我想我应该能够使用 Int
和 Exp
字段的组合来表示任何数字,但我不知道如何到,因为 big.Int
和 `int32' 是整数类型。
从 Postgres 文档 中,我可以看到 numrange 可以采用任何下限和上限中的十进制值,并且数据类型 numeric 是十进制类型的超集。所以我知道我应该能够使用小数,但是 我该怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论