So, I have a very large number that I'm working out in python, but when I try to print it I get something like this:
3.101541146879488e+80
How do I print all the digits of my lovely number?
Try print(type(result)) and you will see it says float . You could type cast it to an integer by doing int(result) , and it will show close to the full number, 30664510802988208128 . It will be a bit off because of the memory size storage limitations of int vs float.
Solution 1: f-String Formatting Within a given f-string, you can use the {...:f} format specifier to tell Python to use floating point notation for the number preceding the :f suffix. Thus, to print the number my_float = 0.00001 non-scientifically, use the expression print(f'{my_float:f}') .
both int
and long
work for this
>>> a
3.101541146879488e+80
>>> int(a)
310154114687948792274813492416458874069290879741385354066259033875756607541870592L
>>> long(a)
310154114687948792274813492416458874069290879741385354066259033875756607541870592L
>>> print (int(a))
310154114687948792274813492416458874069290879741385354066259033875756607541870592
>>> print (long(a))
310154114687948792274813492416458874069290879741385354066259033875756607541870592
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With