+2

how can i get 0.1*3 as 0.30000000000000004

https://code.sololearn.com/cW8zL6VzhvSd/#py

3/31/2020 12:24:14 PM

Mani

2 Answers

New Answer

+2

It's known as a floating point error. See https://en.m.wikipedia.org/wiki/Floating-point_error_mitigation

+6

This generally arises due to floating point error. You can round the value using round function in python Now your code would be: x=round((0.1*3),2) print(x) y = 0.3 print(x>y) print(10 < 10)