选出最接近的数据
var arrs = [0.55,0.75,1.1,1.5,2.2,3,4,5.5,7.5,11,15,18.5,22,30,37,45,55,75,90,110];
var tods=[
100,120,140,160,180,200,220,250,280,320,360,400,450,80,90,110,130,150,170,190,210,240,260,300,340,380,420,500,560,630,700,800,900,1000,1120,1250,1400,1600,1800,2000,480,530,600,670,750,850,950,1060,1180,1320,1500,1700,1900
];
function findCloseNum(arr, num) {
var index = 0;
var d_value = Number.MAX_VALUE;
for (var i = 0; i < arr.length; i++) {
var new_d_value = Math.abs(arr[i] - num);
if (new_d_value <= d_value) {
if (new_d_value === d_value && arr[i] < arr[index]) {
continue;
}
index = i;
d_value = new_d_value;
}
}
return arr[index];
}
h=2.2;
var hh=findCloseNum(arrs, h);
var d=d*1000;
var aa=findCloseNum(tods, d);