0
I have a book which says: "decimal.Decimal( ) function takes an integer or string argument but NOT float"
at first I thought if I provide a float type argument lets say, decimal.Decimal(3.1) then I will get a traceback or an error message. But, I got nothing like that . instead , I got the result as: Decimal('3.100000000000000088881......') (I wish I could paste a screen print of it) so could someone please help me figure out how come I didn't get a traceback if this function gets a float parameter . Many Thanks, Adarsh Namdev
1 Resposta
0
according to python docs ( https://docs.python.org/3/library/decimal.html#decimal-objects ) you can use float, but it might not be the best idea since not all numbers can be acurately represented in float (3.1 seems like one of them) so you might get what you don't expect.