Bas*_*que 0 java bigdecimal compareto
有什么方法可以确定两个BigDecimal对象中的哪一个是比(if或三元运算符)调用更简单的数字(更小)BigDecimal::compareTo?
鉴于:
BigDecimal x = … ;
BigDecimal y = … ;
Run Code Online (Sandbox Code Playgroud)
要么:
if( x.compareTo( y ) < 0 ) {
return x ;
} else {
return y ;
}
Run Code Online (Sandbox Code Playgroud)
要么:
BigDecimal lower = ( x.compareTo( y ) < 0 ) ? x : y ; // If x is smaller than y, use x. If x is greater than or equal to y, use y.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
845 次 |
| 最近记录: |