hours = "40"
hourrate = "$45.07 "
I write the code :
salary = float(hours)*float(hourrate[1:-1])*52.0
why the result on my terminal is 93745.59999999999? (I was handling a .csv file in python)
hours = "40"
hourrate = "$45.07 "
I write the code :
salary = float(hours)*float(hourrate[1:-1])*52.0
why the result on my terminal is 93745.59999999999? (I was handling a .csv file in python)
Floating-point is imprecise. 0.1 + 0.2 != 0.3
. If you need precision, look into using symbolic mathematics like the sympy
module.