当前位置: 首页 > news >正文

最流行的做网站语言邢台建设网站公司

最流行的做网站语言,邢台建设网站公司,搜索引擎网站制作,wordpress 教育插件背景 整型除以整型,正常情况下当然得到的应该也是整型。数据库也是这么干的。 但是在数据库应用中,通常业务的需求是得到NUMERIC,不能直接把小数干掉。 数据库的行为给用户带来了诸多不便,例如1除以2,如果是整型除法会…

背景

整型除以整型,正常情况下当然得到的应该也是整型。数据库也是这么干的。

但是在数据库应用中,通常业务的需求是得到NUMERIC,不能直接把小数干掉。

数据库的行为给用户带来了诸多不便,例如1除以2,如果是整型除法会得到0,然而用户可能要的是0.5。

那么怎么处理呢?

1、建议用户使用float8, money, numeric来存储这种数值。

2、或者在除法时,对操作数进行转换。

操作符

postgres=# \do+ /  List of operators  Schema   | Name |  Left arg type   |  Right arg type  |   Result type    |   Function    |         Description            
------------+------+------------------+------------------+------------------+---------------+------------------------------  pg_catalog | /    | bigint           | bigint           | bigint           | int8div       | divide  pg_catalog | /    | bigint           | integer          | bigint           | int84div      | divide  pg_catalog | /    | bigint           | smallint         | bigint           | int82div      | divide  pg_catalog | /    | box              | point            | box              | box_div       | divide box by point (scale)  pg_catalog | /    | circle           | point            | circle           | circle_div_pt | divide  pg_catalog | /    | double precision | double precision | double precision | float8div     | divide  pg_catalog | /    | double precision | real             | double precision | float84div    | divide  pg_catalog | /    | integer          | bigint           | bigint           | int48div      | divide  pg_catalog | /    | integer          | integer          | integer          | int4div       | divide  pg_catalog | /    | integer          | smallint         | integer          | int42div      | divide  pg_catalog | /    | interval         | double precision | interval         | interval_div  | divide  pg_catalog | /    | money            | bigint           | money            | cash_div_int8 | divide  pg_catalog | /    | money            | double precision | money            | cash_div_flt8 | divide  pg_catalog | /    | money            | integer          | money            | cash_div_int4 | divide  pg_catalog | /    | money            | money            | double precision | cash_div_cash | divide  pg_catalog | /    | money            | real             | money            | cash_div_flt4 | divide  pg_catalog | /    | money            | smallint         | money            | cash_div_int2 | divide  pg_catalog | /    | numeric          | numeric          | numeric          | numeric_div   | divide  pg_catalog | /    | path             | point            | path             | path_div_pt   | divide (rotate/scale path)  pg_catalog | /    | point            | point            | point            | point_div     | divide points (scale/rotate)  pg_catalog | /    | real             | double precision | double precision | float48div    | divide  pg_catalog | /    | real             | real             | real             | float4div     | divide  pg_catalog | /    | smallint         | bigint           | bigint           | int28div      | divide  pg_catalog | /    | smallint         | integer          | integer          | int24div      | divide  pg_catalog | /    | smallint         | smallint         | smallint         | int2div       | divide  
(25 rows)  

显示转换

int 转成 numeric或者float8后再除。

例子

postgres=# select 1/2;  ?column?   
----------  0  
(1 row)  
显示转换任意操作数postgres=# select 1/2.0;  ?column?   
----------  0.5  
(1 row)  postgres=# select 1/2::float8;  ?column?   
----------  0.5  
(1 row)  postgres=# select 1/2::numeric;  ?column?          
------------------------  0.50000000000000000000  
(1 row)  

本篇文章如有帮助到您,请给「翎野君」点个赞,感谢您的支持。

首发链接: https://www.cnblogs.com/lingyejun/p/17678380.html

http://www.yayakq.cn/news/8048/

相关文章:

  • 手机ppt制作成都搜索优化排名公司
  • 做网站用服务器厦门建设工程招标中心网站
  • 天津网站设计网站制作网站开发中用什么安全性比性比较高
  • 南京高端网站制作公司哪家好大连网络备案做网站
  • 赣州新闻联播视频天津seo推广方法
  • 花都网站制作公司seo系统教程
  • 网站开发定制多少钱做网站时背景图片浮动
  • 淘宝客网站推广怎么做网站内链wordpress插件
  • 百度流量统计长沙网站托管优化
  • 济南企业网站yzipi wordpress
  • 湖南做网站kaodezhu嘉定集团网站建设
  • 潍坊网站制作江门公司dede多个网站怎么做
  • 怎么利用自媒体做网站优化建设电脑网站
  • 南京网站设计培训价格wordpress安装插件500
  • 大型网站建设用什么系统好网站域名需icp备案吗
  • 济源做网站的好公司免费搭建企业网站
  • 什么网站做聚乙烯醇好的公司logo设计免费生成软件
  • 网页设计中用div做网站例子优化网站收费标准
  • 湖州猪八戒做网站wordpress 文章广告
  • 电商网站设计目的html音乐播放器代码
  • 网站建设 gei l f网站 配色方案
  • 简单的网站开发流程js网站统计
  • 网站首页phpcms怎么添加卖渔具的亲戚做网站
  • 山西建设集团网站有什么网站可以做浏览单
  • 农产品信息网站建设方案关键词是指什么
  • 简洁大气企业网站源码 后台公司网站建设哪儿济南兴田德润实惠吗
  • 企业网站建设的申请河南如何优化网站
  • 阿里云建站和华为云建站网站开发和网络安全
  • 网上做衣服的网站网站开发前景知乎
  • 广西建设学院网站首页唐山建设工程信息网站