PG 浮点数精度显示问题
原创
©著作权归作者所有:来自51CTO博客作者岳麓丹枫的原创作品,请联系作者获取转载授权,否则将追究法律责任
create table test(id double precision);
insert into test values (1.1234567890123456789);
insert into test values (1.1234567890012345678);
insert into test values (1.1234567890012545678);
insert into test values (10.1234567890012545678);
insert into test values (123.012345678901234567);
select * from test;
id
------------------
1.12345678901235
1.12345678900123
1.12345678900125
10.1234567890013
123.012345678901
1.12345678901235
1.12345678900123
1.12345678900125
10.1234567890013
123.012345678901
(10 rows)
postgres=# show extra_float_digits ;
extra_float_digits
--------------------
1
(1 row)
postgres=# set extra_float_digits to 3;
SET
postgres=#
postgres=# show extra_float_digits ;
extra_float_digits
--------------------
3
(1 row)
postgres=# select id from test SF;
id
---------------------
1.12345678901234569
1.12345678900123458
1.12345678900125456
10.1234567890012546
123.012345678901241
1.12345678901234569
1.12345678900123458
1.12345678900125456
10.1234567890012546
123.012345678901241