0

Is it possible in python, that for example 3.8-3 is 0.8000000000.... or with any other integer?

21st Oct 2017, 6:05 PM
lars
6 Answers
+ 2
Without writing your own class and overriding the operation magic methods (assumedly to do it in strings), there's "import mpmath" http://mpmath.org because...here's 0.8 natively in straight Python: print("{:.52f}".format(0.8)) 0.8000000000000000444089209850062616169442667236328125
21st Oct 2017, 9:56 PM
Kirk Schafer
Kirk Schafer - avatar
0
Oh I meant float* not integer
21st Oct 2017, 6:08 PM
lars
0
I want that: Input: x=3.8 z=x-int (x) Output: 0.8
21st Oct 2017, 6:58 PM
lars
0
print (z)***
21st Oct 2017, 6:59 PM
lars
- 1
what exactly u wantt
21st Oct 2017, 6:55 PM
sayan chandra
sayan chandra - avatar
- 1
its floting point precision.. ans will be like that 0.799999999998
21st Oct 2017, 7:02 PM
sayan chandra
sayan chandra - avatar