I have h
, and D
, of type double
and int
.
There are 5 h
values for each D
, and I put them in an array.
For h
values that are integers, I did not append .0
, e.g. 79 instead of 79.0
When I did division on this array, I get 79/50 = 1
For example,
h: 90.5 D: 45 h/d: 2.01111111111
h: 90.3 D: 45 h/d: 2.00666666667
h: 90.3 D: 45 h/d: 2.00666666667
h: 90.2 D: 45 h/d: 2.00444444444
h: 90 D: 45 h/d: 2
h: 79.2 D: 50 h/d: 1.584
h: 79 D: 50 h/d: 1
h: 78.2 D: 50 h/d: 1.564
h: 78 D: 50 h/d: 1
h: 77.8 D: 50 h/d: 1.556
h: 69.5 D: 55 h/d: 1.26363636364
h: 69.2 D: 55 h/d: 1.25818181818
h: 68.9 D: 55 h/d: 1.25272727273
h: 68.7 D: 55 h/d: 1.24909090909
h: 69.2 D: 55 h/d: 1.25818181818
This is easily fixed when I replace 79 with 79.0. However I am curious why this is happening.
arr = OrderedDict()
arr[40] = [[93.9, 95.3, 95.3, 93.2, 93.2], []]
arr[45] = [[90.5, 90.3, 90.3, 90.2, 90], []]
arr[50] = [[79.2, 79, 78.2, 78, 77.8], []]
for D in arr:
v = arr[D]
for h in v[0]:
print "h:", h, "D:", D, "h/D:", h/D
v[1].append(round(h/D, 3))