Oracle NUMBER比较 [英] Oracle NUMBER Comparisons

查看:419
本文介绍了Oracle NUMBER比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常在编程中,不应比较浮点数据类型的相等性,因为存储的值通常是近似值.

Generally in programming, the floating point data types should not be compared for equality since the values stored are very often an approximation.

两个非整数Oracle NUMBER值存储方式不同(以10为底),是否可以可靠地比较它们的相等性?

Can two non-integer Oracle NUMBER values be compared reliably for equality since they are stored differently (base-10)?

推荐答案

是的,Oracle NUMBER类型是精确的.与浮点/双精度类型相比,它们更像是带刻度的整数.因此NUMBER(10,3)具有10位数字,在小数点后3位,这实际上是一个10位整数,小数位数为3.实际上,这就是Java BigDecimals的工作方式的精确之处(内部是BigInteger加上小数位数).

Yes, Oracle NUMBER types are precise. They're more like integers with a scale than float/double types. So a NUMBER(10,3) has 10 digits, 3 after the decimal point, which is really a 10 digit integer with a scale of 3. In fact, that's precise how Java BigDecimals work (being a BigInteger plus a scale internally).

这篇关于Oracle NUMBER比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆