How to split large numbers without python abbreviating it?

Asked

Viewed 40 times

-2

Whenever I try to do calculations in python with large numbers, it ends up abbreviating the result.

For example:

a = 8682372684397235357614080000
b = 86400
c = a/b

print(c)
1.0049042458793097e+23 \\resultado

I’d like to print the whole number.

1 answer

0

To take the whole number, you must use a formatted "string", i.e., to determine how it will be printed on the screen:

The "float" type can be formatted in these ways:

  • :.0f # no zeros left
  • :.2f# with two zeros

Note: you can put more than 2 only.

In this case

a = 8682372684397235357614080000
b = 86400

c = a/b # divisão normal

print(f"{c:.0f}") # :.0f sem zeros a esquerda

Result: 100490424587930965114880

Browser other questions tagged

You are not signed in. Login or sign up in order to post.