I'm creating a dictionary with this simple code:
pixel_histogram = {}
min_value = -0.2
max_value = 0.2
interval_size = (math.fabs(min_value) + math.fabs(max_value))/bins
for i in range(bins):
key = min_value+(i*interval_size)
print key
pixel_histogram[key] = 0
print pixel_histogram
But I'm a little surprised 'cause I got these values with my prints:
#Printing keys
-0.2
-0.16
-0.12
-0.08
-0.04
0.0
0.04
0.08
0.12
0.16
#Printing the dictionary
{0.0: 0,
-0.08000000000000002: 0,
0.15999999999999998: 0,
-0.16: 0,
0.12: 0,
-0.12000000000000001: 0,
0.08000000000000002: 0,
-0.04000000000000001: 0,
-0.2: 0,
0.03999999999999998: 0}
I didn't figure out why the values are different and how could I solve this. Any help would be appreciated. Thanks.