how can i get 0.1*3 as 0.30000000000000004


3/31/2020 12:24:14 PM


2 Answers

New Answer


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


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)