Home > Database > Mysql Tutorial > Firebird里如何在提交数据前做四舍五入?

Firebird里如何在提交数据前做四舍五入?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:56:42
Original
1387 people have browsed it

很多时候,在存储过程或触发器里经过运算后的数字要写入记录,但这种运算的结果数字往往是个无限小数,所以需要预先做个四舍五入,如金额一般是保留两位小数。 Firebird2.1开始,增加了很多内置函数,这样,以前很多不得不通过UDF做的事,就可以直接使用了。

很多时候,在存储过程或触发器里经过运算后的数字要写入记录,但这种运算的结果数字往往是个无限小数,香港服务器,香港服务器租用,所以需要预先做个四舍五入,香港虚拟主机,如金额一般是保留两位小数。

Firebird2.1开始,增加了很多内置函数,这样,以前很多不得不通过UDF做的事,就可以直接使用了。

如Trunc()函数,就可以用来做四舍五入的数据转换了。

如这段代码:

fAmount = TRUNC((fAmount * fdiscount * fNumber / fTotal), 2)

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template