Thus, using simple data types, such as string, integer, float, and even BigDecimal, are natural.
因此,可以自然地使用简单的数据类型,比如string、integer、float,甚至是BigDecimal。
If you need to represent fixed point Numbers, such as dollars and cents, use BigDecimal instead.
如果需要表示定点数(譬如,几美元和几美分),则使用BigDecimal。
Because BigDecimal objects are immutable, each of these methods produces a new BigDecimal object.
由于BigDecimal对象是不可变的,这些方法中的每一个都会产生新的BigDecimal对象。
For this reason, BigDecimal gives you explicit control over rounding when performing division operations.
出于这个原因,在进行除法运算时,BigDecimal可以让您显式地控制舍入。
If you are looking to represent exact quantities such as monetary amounts, BigDecimal is well-suited to the task.
如果您正在寻找一种能精确表示如货币量这样的数值,则BigDecimal可以很好地胜任该任务。
In Listing 10, the quantity starts the method call, which moves through Integer, then BigDecimal, finally returning an Ingredient.
在清单10中,数量开始方法调用,开始是Integer,然后是BigDecimal,最后返回Ingredient。
Conversion from BigDecimal objects into Float Numbers had a problem which enables attackers to effectively cause segmentation faults.
将BigDecimal对象转换成float数的时候会导致一个问题,这个问题使得攻击者能够很容易得到段错误。
Of course, if you really do need the extra precision, then you'll need to pick a data type with more precision, such as a double or a BigDecimal.
当然,如果一定需要额外的精度,则可以选择具有高精度的数据类型,比如double或BigDecimal。
You should be careful with the BigDecimal (double) constructor because it can allow rounding errors to sneak into your calculations before you know it.
要小心使用BigDecimal (double)构造函数,因为如果不了解它,会在计算过程中产生舍入误差。
BigDecimal is a standard class, with no special support in the compiler, to represent arbitrary-precision decimal Numbers and perform arithmetic on them.
BigDecimal是标准的类,在编译器中不需要特殊支持,它可以表示任意精度的小数,并对它们进行计算。
Improper use of the BigDecimal(double) constructor can show up as strange-seeming exceptions in JDBC drivers when passed to the JDBC setBigDecimal() method.
如果使用BigDecimal(double)构造函数不恰当,在传递给JDBCsetBigDecimal()方法时,会造成似乎很奇怪的 JDBC 驱动程序中的异常。
Two BigDecimal values that represent the same number, but have different scale values (for instance, 100.00 and 100.000) will not be considered equal by the equals() method.
equals() 方法认为,两个表示同一个数但换算值不同(例如, 100.00和 100.000 )的BigDecimal 值是不相等的。
As a result, BigDecimal is not well-suited for intensive numeric calculation because of the object creation overhead, but it is designed for representing exact decimal Numbers.
因此,因为创建对象的开销,BigDecimal不适合于大量的数学计算,但设计它的目的是用来精确地表示小数。
Internally, BigDecimal is represented as an arbitrary-precision unscaled value and a scale factor, which represents how many places to move the decimal point left to obtain the scaled value.
在内部,可以用任意精度任何范围的值和一个换算因子来表示BigDecimal,换算因子表示左移小数点多少位,从而得到所期望范围内的值。
Internally, BigDecimal is represented as an arbitrary-precision unscaled value and a scale factor, which represents how many places to move the decimal point left to obtain the scaled value.
在内部,可以用任意精度任何范围的值和一个换算因子来表示BigDecimal,换算因子表示左移小数点多少位,从而得到所期望范围内的值。
应用推荐