python - Generating a list with foating point values -


this question has answer here:

i wish generate list these value:

[0,0.01,0.02...0.49] 

and though correct way it:

[0.01*i in range(50)] 

but horror observed following:

>>> 35*0.01 0.35000000000000003 >>> float("0.35") 0.35 

what doing wrong? if understand correctly seems 35*0.01 not give closest floating point representation of 0.35 float("0.35") does.

to guarantee nearest valid floating point number, need start values exact. 0.01 isn't exact, 100.0 is.

[i/100.0 in range(50)] 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -