PostgreSQL学习篇9.3 浮点数类型

PostgreSQL学习篇9.3 浮点数类型,第1张

概述浮点数类型有:real、double precision,它们是不精确的、变精度的数字类型。注意:1.要求精确计算的,需要使用numeric2.浮点数等值比较,可能不是想象中的结果。浮点类型的特殊值: * infinity (正无穷) * -infinity (负无穷) * NaN (不是一个数字not a number示例:postgres=# ins
浮点数类型有:real、double precision,它们是不精确的、变精度的数字类型。注意:1.要求精确计算的,需要使用numeric2.浮点数等值比较,可能不是想象中的结果。浮点类型的特殊值:	* infinity  (正无穷)	* -infinity  (负无穷)	* NaN       (不是一个数字not a  number示例:postgres=# insert into test(col1) values ('InFiNity');ERROR:  invalID input Syntax for type numeric: "InFiNity"liNE 1: insert into test(col1) values ('InFiNity');      ----numeric没有infinitypostgres=# create table testflo(col1 real,col2 double precision);CREATE tablepostgres=# \d testflo        table "public.testflo" Column |       Type       | ModifIErs--------+------------------+----------- col1   | real             | col2   | double precision |postgres=# insert into testflo values('InfInitY','-InfiniTY');INSERT 0 1postgres=# insert into testflo values('InfiNity','nan');INSERT 0 1postgres=# select * from testflo;   col1   |   col2   ----------+----------- Infinity | -Infinity Infinity |       NaN(2 rows)postgres=#
总结

以上是内存溢出为你收集整理的PostgreSQL学习篇9.3 浮点数类型全部内容,希望文章能够帮你解决PostgreSQL学习篇9.3 浮点数类型所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/1173655.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存