如何比较三个BigDecimal值 [英] How to compare three BigDecimal values

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

问题描述

我需要像这样比较三个Bigdecimal值。
例如:

I need to compare three Bigdecimal values like this. Eg:

    if(Min<=Value<=Max){
     //Do this
    }else{
     //Do this
    }

所有三个值是BigDecimals.How如何在Java中进行比较。
谢谢。
Anuradha。

All three values are BigDecimals.How to compare like this in Java. Thanks. Anuradha.

推荐答案

您需要使用 compareTo
您提供的示例如下:

You need to use compareTo. The example you provide would be:

if(Min.compareTo(Value)<=0 && Max.compareTo(Value) >=0){
     //Do this
    }else{
     //Do this
    }

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

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