BigDecimal判端为0
时间: 2023-11-07 07:15:16 浏览: 230
BigDecimal使用
BigDecimal可以通过compareTo方法来判断是否为0。compareTo方法返回一个整数,表示调用对象与指定BigDecimal对象的比较结果。如果返回值为0,则表示两个BigDecimal对象相等。因此,可以通过调用compareTo方法,将0作为参数传入,来判断BigDecimal是否为0。例如,假设我们有一个BigDecimal对象bd,我们可以使用以下代码来判断bd是否为0:
int result = bd.compareTo(BigDecimal.ZERO);
if(result == 0) {
// bd等于0
} else {
// bd不等于0
} <span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [接收前端传到后台的参数,类型:BigDecimal、String、Integer、Long等,效验接收的参数是否超过几位小数点...](https://blog.csdn.net/qq_44840230/article/details/114434229)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Java学习笔记(七)集合,泛型,工具类,BigDecimal](https://blog.csdn.net/a2240386260/article/details/119855096)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [Java BigDecimal类用法详解](https://download.csdn.net/download/weixin_38611388/12796584)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文