Decimals in python

A

arslanburney

Hello. New to using Python. Python automatically round off watver i
calculate using the floor function. How wud i make the exact value
appear?

Tried out fabs() in the math library but still confused. Cud some1
elaborate on it.
 
A

Aidan

Hello. New to using Python. Python automatically round off watver i
calculate using the floor function. How wud i make the exact value
appear?

Tried out fabs() in the math library but still confused. Cud some1
elaborate on it.

If you're working with integers, the result will always be an integer:
3

How ever if you add a float into the mix:
3.3333333333333335

HTH
 
E

Ethan Furman

Hello. New to using Python. Python automatically round off watver i
calculate using the floor function. How wud i make the exact value
appear?

Tried out fabs() in the math library but still confused. Cud some1
elaborate on it.

[python]
---help(math.floor):
Help on built-in function floor in module math:

floor(...)
floor(x)

Return the floor of x as a float.
This is the largest integral value <= x.
[/python]

The whole point of floor() is to round down. If you want to see all the
decimals, don't use floor(), and follow Aidan's advice to have at least
one floating-point number in the calculation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top