Decimals in python

Discussion in 'Python' started by arslanburney, Jun 16, 2008.

  1. arslanburney

    arslanburney Guest

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

    Tried out fabs() in the math library but still confused. Cud some1
    elaborate on it.
    arslanburney, Jun 16, 2008
    1. Advertisements

  2. arslanburney

    Aidan Guest

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

    How ever if you add a float into the mix:

    Aidan, Jun 16, 2008
    1. Advertisements

  3. arslanburney

    Ethan Furman Guest

    Help on built-in function floor in module math:


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

    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.
    Ethan Furman, Jun 18, 2008
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.