当前位置:网站首页>记一次List对象遍历及float类型判断大小
记一次List对象遍历及float类型判断大小
2022-06-27 19:37:00 【可是我还饿啊】
1.对于float类型的数值比较,为了避免精度损失用到了
BigDecimal类
自己封装的工具类
package OPCutils;
import java.math.BigDecimal;
public class We {
public int floatCompare(float a, float b) {
BigDecimal bd1 = BigDecimal.valueOf(a);
BigDecimal bd2 = BigDecimal.valueOf(b);
return bd1.compareTo(bd2);
}
}
具体实现
public void zongceshi(){
OpcSOS opcSOS=new OpcSOS();
List<String> list = opcSOS.luxun();
We we = new We();
List<PlcdataDO> plclist=new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
PlcdataDO plcdataDOS = plcdataDao.selectSub(list.get(i));
plclist.add(plcdataDOS);
}
List<PlcdataDO> plclist1=new ArrayList<>();
for (PlcdataDO plcdataDO:plclist){
int i = we.floatCompa边栏推荐
猜你喜欢

The create database of gbase 8A takes a long time to query and is suspected to be stuck

Experience sharing of meituan 20K Software Test Engineers

Bit.Store:熊市漫漫,稳定Staking产品或成主旋律

.NET学习笔记(五)----Lambda、Linq、匿名类(var)、扩展方法
How to design an elegant caching function

管理系統-ITclub(下)

Open source technology exchange - Introduction to Chengying, a one-stop fully automated operation and maintenance manager

Express e stack - small items in array

Système de gestion - itclub (II)

Go from introduction to practice - Interface (notes)
随机推荐
win11桌面出现“了解此图片”如何删除
Experience sharing of meituan 20K Software Test Engineers
软件测试自动化测试之——接口测试从入门到精通,每天学习一点点
Have time to look at ognl expressions
美团20k软件测试工程师的经验分享
Software test automation test -- interface test from entry to proficiency, learn a little every day
Go从入门到实战——错误机制(笔记)
百万年薪独家专访,开发人员不修复bug怎么办?
管理系统-ITclub(下)
Burp suite遇到的常见问题
"Apprendre cette image" apparaît sur le Bureau win11 comment supprimer
Go from starting to Real - Interface (note)
C语言程序设计详细版 (学习笔记1) 看完不懂,我也没办法。
Luogu p5706 redistributing fertilizer and house water
Simulink method for exporting FMU model files
Go从入门到实战——任务的取消(笔记)
单元测试界的高富帅,Pytest框架,手把手教学,以后测试报告就这么做~
Array assignment
[LeetCode]513. 找树左下角的值
At 19:00 on Tuesday evening, the 8th live broadcast of battle code Pioneer - how to participate in openharmony's open source contribution in multiple directions