How do I make the decimal go on?

  • Thread starter Cash Fulton
  • Start date
In summary: Python which would chop off the extra digits anyway.In summary, the conversation discusses the concept of Planck length and the difficulty in accurately measuring objects at this scale. The code provided attempts to subtract a very small number from a larger one, but this does not make logical sense and there is no way to accomplish this with standard double precision calculations. Special software or paper and pencil calculations can be used to handle the extra levels of precision.
  • #1
Cash Fulton
24
1
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.
 
Technology news on Phys.org
  • #2
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
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.
 
  • Like
Likes Borg and artyb
  • #4
Orodruin said:
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.

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.
 
  • Like
Likes DaveC426913
  • #5
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.
 
  • #6
Cash Fulton said:
>shines light on you
I said answer the question!

Orodruin said:
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.
Cash Fulton said:
Protip: I was role playing in a non-threatening way to enlighten you. I did not succeed.
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!".
 
  • #7
Cash, I got the intended meaning.
Cash Fulton said:
Protip: I was role playing in a non-threatening way to enlighten you. I did not succeed.
But you probably mean to 'lighten the mood'. To 'enlighten a person' means something very different. :wink:

Anyway, Cash, you'll want to ensure that the input and output are cast into "double precision" floating point decimals.
 
  • #8
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)
 

FAQ: How do I make the decimal go on?

1. How do I convert a fraction to a decimal?

To convert a fraction to a decimal, divide the numerator (top number) by the denominator (bottom number). The resulting number will be the decimal form of the fraction.

2. What is the easiest way to multiply a decimal by a whole number?

The easiest way to multiply a decimal by a whole number is to first ignore the decimal and multiply the two numbers as if they were both whole numbers. Then, count the number of digits after the decimal point in the original decimal and move the decimal point in the product that many places to the left. If there are not enough digits, add zeros to the end of the product.

3. How do I add or subtract decimals?

To add or subtract decimals, line up the decimal points and then perform the addition or subtraction as normal. If one number has fewer digits after the decimal point than the other, add zeros to the end to make the numbers have the same number of digits after the decimal point.

4. How do I compare two decimals?

To compare two decimals, start from the left and compare the digits one by one until you reach a point where the digits are different. The decimal with the larger digit at that point is the larger number. If the digits are the same for both decimals, continue comparing until you reach the end. If all digits are the same, the decimals are equal.

5. What do I do if the decimal doesn't go on forever?

If the decimal doesn't go on forever, it is known as a terminating decimal. This means that the decimal has a finite number of digits after the decimal point. To show that the decimal is terminating, you can write a line over the last digit or simply write the decimal in its original form without any additional notation.

Similar threads

Replies
1
Views
3K
Replies
4
Views
4K
Replies
3
Views
2K
Replies
1
Views
3K
Replies
16
Views
2K
Back
Top