# How do I make the decimal go on?

1. Oct 10, 2015

### Cash Fulton

I was bored so I made this:

print("Object vs. Planck Length")
print("How long is the object in meters?")
obj = int(input())
result = obj - 0.000000000000000000000000000000000016162
print("1 planck length is " + str(result) + " meters smaller than that object.")

Problem is that the decimal doesn’t carry all the way to 16162. For example, I'll get the output:

Object vs. Planck Length
How long is the object in meters?
4
Planck Length is 4.0 smaller than that object.

What would be the fix? Thanks.

2. Oct 10, 2015

### Orodruin

Staff Emeritus
The question is why you would even want to do this computation. No length at the scale of a meter is going to be known to within one planck length and your program is therefore already correct in terms of possible significant digits. A more meaningful quantity would be the ratio.

3. Oct 10, 2015

### Cash Fulton

>shines light on you

4. Oct 10, 2015

### Orodruin

Staff Emeritus
Your number is far too small for the typical working precision to notice a difference from 4 - and for good reason - there are very few cases where you would actually want to take a difference between numbers with such different size.

Also, remember that you are asking people to help you for free. An interrogative attitude such as the one you just displayed will only act to alienate the people you are asking for help.

5. Oct 10, 2015

### Cash Fulton

So is there or is there not anyway of accomplishing this?

Protip: I was role playing in a non-threatening way to enlighten you. I did not succeed.

6. Oct 10, 2015

### Staff: Mentor

This part is correct:
The default level of precision for most computer languages using floating point operations (decimal arithmetic) on an X86 (windows/Linux desktop) is going to be 15 decimals. The answer here involves more than double that number.

This part is an analogy since the idea of subtracting numbers like you did does not "work":
You are subtracting the "length of an ant" from the "length" of a galaxy. The ant is lost in the calculation. So it does not make any logical sense to do what you are trying. Or as Orudruin said, the answer 4 is scientifically correct, since nothing can be measured simultaneously at those two different scales.

If you insist on getting arithmetically correct answers (for a problem that does not make lots of sense to people who understand), use and install numpy, or if you have Linux try C and gmp. You need special software to handle the extra levels of precision correctly. So in effect you are giving up speedy calculations for much slower extended precision arithmetic operations.

Paper and pencil works, too. Since you want to make this work, telling us your OS and what programming tools you are now using would help.

7. Oct 11, 2015

### Staff: Mentor

I'm 100% with Orodruin here. Your request comes off as very demanding, which is NOT the way to convince people to spend time helping you. The appropriate attitude is "please help me" not "tell me now!".

8. Oct 11, 2015

### DaveC426913

Cash, I got the intended meaning.
But you probably mean to 'lighten the mood'. To 'enlighten a person' means something very different.

Anyway, Cash, you'll want to ensure that the input and output are cast into "double precision" floating point decimals.

9. Oct 11, 2015

### FactChecker

It looks like Python has a package to do calculations with a large number of significant digits. See http://pythonhosted.org/bigfloat/ The calculation you are trying requires 41 significant digits, It is far beyond what standard double precision calculations can do (15-17 significant digits)