How do I make the decimal go on?

  • Thread starter Thread starter Cash Fulton
  • Start date Start date
AI Thread Summary
The discussion revolves around a Python program designed to compare an object's length in meters to the Planck length. The user encounters an issue where the output does not reflect the intended precision, as the decimal does not carry sufficiently to represent the difference accurately. Participants highlight that measuring lengths at such vastly different scales (like a meter versus a Planck length) is impractical, as the difference is negligible within typical measurement precision. Suggestions include using libraries like NumPy or BigFloat for higher precision calculations, as standard floating-point operations are limited to about 15-17 significant digits. Additionally, the tone of the user's request is critiqued for being demanding, which may discourage others from offering help. The conversation emphasizes the importance of a respectful approach when seeking assistance in forums.
Cash Fulton
Messages
24
Reaction score
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
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.
 
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
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
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.
 
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!".
 
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.
 
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)
 
Back
Top