arrays - VBA compare Abs() values not working -
i have 2 arrays of data want compare every element in both arrays , put biggest absolute value in new array. see code below:
if abs(dataarray1(i)) < abs(dataarray2(i)) newdataarray(i) = dataarray2(i) else newdataarray(i) = dataminarray(i) end if the probem of values decimals , if compare example -1.02 , 1.0100 normaly -1.02 has bigger abs value. in case program returns 1.0100 , happens values not same length. longer 1 returned. how happen , wrong?
are arrays of string type? otherwise couldn't explain why values 1.0100 exist. value should automatically shown 1.01
if working strings try convert values floats. work: abs(cdbl(dataarray1(i))) < abs(cdbl(dataarray2(i)))
Comments
Post a Comment