当前位置: 首页 > news >正文

武汉 网站建设公司苏州百度代理公司

武汉 网站建设公司,苏州百度代理公司,wordpress lms插件,上海机械网站建设jwensh2023.12.20 使用背景 对 web3 相关的数据进行计算的时候,需要进行大小加减计算,UI 自动化过程需要将数据转为自然数;页面获取的数据会有千分位 、高精度(18位) /*** Compares this {code BigDecimal} with the specified* {code BigDe…

jwensh@2023.12.20

使用背景

对 web3 相关的数据进行计算的时候,需要进行大小加减计算,UI 自动化过程需要将数据转为自然数;页面获取的数据会有千分位高精度(18位)

    /*** Compares this {@code BigDecimal} with the specified* {@code BigDecimal}.  Two {@code BigDecimal} objects that are* equal in value but have a different scale (like 2.0 and 2.00)* are considered equal by this method.  This method is provided* in preference to individual methods for each of the six boolean* comparison operators ({@literal <}, ==,* {@literal >}, {@literal >=}, !=, {@literal <=}).  The* suggested idiom for performing these comparisons is:* {@code (x.compareTo(y)} &lt;<i>op</i>&gt; {@code 0)}, where* &lt;<i>op</i>&gt; is one of the six comparison operators.** @param  val {@code BigDecimal} to which this {@code BigDecimal} is*         to be compared.* @return -1, 0, or 1 as this {@code BigDecimal} is numerically*          less than, equal to, or greater than {@code val}.*/public int compareTo(BigDecimal val) {// Quick path for equal scale and non-inflated case.if (scale == val.scale) {long xs = intCompact;long ys = val.intCompact;if (xs != INFLATED && ys != INFLATED)return xs != ys ? ((xs > ys) ? 1 : -1) : 0;}int xsign = this.signum();int ysign = val.signum();if (xsign != ysign)return (xsign > ysign) ? 1 : -1;if (xsign == 0)return 0;int cmp = compareMagnitude(val);return (xsign > 0) ? cmp : -cmp;}

比较方法

  • 与开发讨论过,后端业务中比较常用的是 BigDecimal
  • BigDecimal 类提供 compareTo() 方法来比较两个数的大小
    • 例如:a = b 返回0 ; a < b返回-1 ; a > b返回1
    • 通过这三种比较返回的结果,我们还可以比较 a != b、a >= b和a<= b这三种情况。
import java.math.BigDecimal;public class Web3WalletTest {public static void main(String[] args) {BigDecimal a = new BigDecimal("213.003");BigDecimal b = new BigDecimal("213.004");BigDecimal c = new BigDecimal("213.003");/**** 大于 和 小于*/// a>b --> falseboolean b1 = a.compareTo(b) == 1;System.err.println("b1:" + b1);if (a.compareTo(b) == 1)System.out.println("a > b");// a<b --> trueboolean b2 = a.compareTo(b) == -1;System.err.println("b2:" + b2);if (a.compareTo(b) == -1)System.out.println("a < b");/**** 大于等于*/// a>=b --> falseboolean b3 = a.compareTo(b) > -1;System.err.println("b3:" + b3);if (a.compareTo(b) != -1)System.out.println("a >= b");// a>=c --> trueboolean b4 = a.compareTo(c) > -1;System.err.println("b4:" + b4);/**** 小于等于*/// a<=b --> trueboolean b5 = a.compareTo(b) < 1;System.err.println("b5:" + b5);if (a.compareTo(b) != 1)System.out.println("a <= b");// a<=c --> trueboolean b6 = a.compareTo(c) < 1;System.err.println("b6:" + b6);/**** 等于*/// a=c --> trueboolean b7 = a.compareTo(c) == 0;System.err.println("b7:" + b7);if (a.compareTo(b) == 0)System.out.println("a = b");if (a.compareTo(b) != 0)System.out.println("a != b");}
}
  • 用例里使用的方式
BigDecimal btteBalance = new  BigDecimal(walletPage.getTokenBalance(3).getText().replace(",", ""));
Assert.assertTrue(btteBalance.compareTo(new BigDecimal("0")) > -1);
http://www.ds6.com.cn/news/119107.html

相关文章:

  • 网站建设公司招聘拉新注册app拿佣金
  • 厦门国外网站建设公司哪家好友链
  • 网站建设价格女网站服务器失去响应
  • 自己做的网站抬头在哪里改百度建站平台官网
  • 如何投放网络广告万能优化大师下载
  • 怎样学习网站建设杭州云优化信息技术有限公司
  • wordpress 4.5 多站点不同数据吉林关键词优化的方法
  • wordpress音乐单独播放器广州网站优化外包
  • 开发网站手机版抖音seo供应商
  • wordpress 公告插件苏州seo关键词排名
  • 百度站长平台快速收录怎么弄广告免费推广网
  • 做网站用的是什么语言网络营销步骤
  • 珠海建站网站模板广州疫情最新情况
  • 河北提供网站制作公司电话今日头条极速版官网
  • 单位做网站费用怎么记账东莞网站建设快速排名
  • 怎样用hbuilder做网站常用的营销方法和手段
  • 允许个人做动漫网站吗做网络优化的公司排名
  • 专门做企业名录的网站近三天时政热点
  • 电器网站建设深圳百度seo公司
  • 济南网站建设公司哪个好做网页的网站
  • web用框架做网站百度识图网页入口
  • 深圳知名工业设计公司seo自动优化软件下载
  • wordpress 行间距插件东莞seo建站公司哪家好
  • 网站建设背景网站推广的要点
  • 现在海外做的比较好一点的网站国外网络推广
  • dw如何做网站后台媒体发稿费用
  • 做网站开发的步骤seo网站结构优化
  • wordpress文章美化seo整站优化什么价格
  • 北京网站备案福州百度推广优化排名
  • 图怪兽logo设计官网商品关键词怎么优化