How do I make the decimal go on?

  • Thread starter Thread starter Cash Fulton
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around a programming question related to performing arithmetic operations involving very small numbers, specifically the Planck length, in Python. Participants explore issues of numerical precision and the appropriateness of the computation in the context of significant digits.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant presents a Python code snippet attempting to calculate the difference between a user-defined length and the Planck length, expressing frustration over the output precision.
  • Another participant questions the necessity of such a computation, suggesting that no length at the scale of a meter can be known to within one Planck length, thus rendering the computation meaningless in practical terms.
  • Some participants argue that the difference between vastly different magnitudes (like a meter and a Planck length) is not significant enough to warrant such calculations, emphasizing the limitations of typical floating-point precision.
  • There are suggestions to use specialized libraries, such as numpy or bigfloat, to handle calculations requiring higher precision, as standard floating-point operations may not suffice.
  • Several participants express concern over the tone of the original poster's request for help, suggesting that a more polite approach would be beneficial in eliciting assistance.
  • One participant attempts to clarify the meaning of "enlighten" in the context of the discussion, while also addressing the need for double precision in input and output for the calculations.

Areas of Agreement / Disagreement

Participants generally disagree on the validity and necessity of the computation involving the Planck length, with some emphasizing the impracticality of such calculations while others focus on the technical aspects of achieving higher precision in programming.

Contextual Notes

Limitations include the dependence on the definitions of precision in floating-point arithmetic and the unresolved nature of whether such calculations are meaningful in the context of physical measurements.

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   Reactions: 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   Reactions: 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)
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 28 ·
Replies
28
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
17K
  • · Replies 20 ·
Replies
20
Views
3K