First off all, thanks for the attention, I'm new to this site ^^ so excuse me if I do something wrong...
I have a huge problem with my Python code... I'm new to programming, and I'm new to Python as well.
I need to take a floating point number and move the point right so it becomes an integer, like taking 60.27 and getting 6027.
The algorithm that I'm using is recursively multiplying num*10
until num%2==0
, then getting the int(num)
.
The problem is, when I multiply (for example) 602.47*10
it returns 6024.700000000001
and it obviously doesn't work :-)
Is there any way to fix it, or any other technique or other way to do this recursively?? I'm allowed to use anything I need, but its got to be recursive: no for
or while
...
Thanks for the help!! My first language is not english, so I beg your pardon if it's hard to read...