Insights Rating: Is Precision Necessary?
- Context: Bug
- Thread starter DrClaude
- Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
8 replies · 2K views
Physics news on Phys.org
- 19,954
- 11,048
I changed the number of significant digits displayed in floating point numbers from 14 to 17. Might be what caused this issue. I'll revert back to 14.
- 37,492
- 14,381
Change it to 3 or 2? There is no point in having more.
- 19,954
- 11,048
Default is 14, so there must be some reason the PHP devs think it's a good value.mfb said:Change it to 3 or 2? There is no point in having more.
- 7,467
- 2,988
http://php.net/manual/en/function.round.php
from http://php.net/manual/en/function.printf.php
from http://php.net/manual/en/function.printf.php
Code:
You can use this function to format the decimal places in a number:
$num = 2.12;
printf("%.1f",$num);
prints:
2.1
- 37,492
- 14,381
Well, if it is a general PHP setting: PHP has no idea how precise these numbers are supposed to be. 14 is small enough to avoid displaying rounding errors in most cases, and large enough to keep more digits than anyone is reasonably interested in (with extremely few exceptions).Greg Bernhardt said:Default is 14, so there must be some reason the PHP devs think it's a good value.
Similar threads
Undergrad
Number of Sig Figures and Precision
- fog37
- · Replies 20 ·
- Classical Physics
- Replies
- 20
- JC_Silver
- · Replies 27 ·
- STEM Educators and Teaching
- Replies
- 27
- shivajikobardan
- · Replies 1 ·
- Programming and Computer Science
- Replies
- 1
- lionpauu
- · Replies 6 ·
- Mechanics
- Replies
- 6
- CrazyNinja
- · Replies 5 ·
- Feedback and Announcements
- Replies
- 5
- fog37
- · Replies 29 ·
- Programming and Computer Science
- Replies
- 29
- Heidi
- · Replies 25 ·
- Quantum Interpretations and Foundations
- Replies
- 25
- e2m2a
- · Replies 9 ·
- Special and General Relativity
- Replies
- 9
- Malamala
- · Replies 10 ·
- Atomic and Condensed Matter
- Replies
- 10
- kevincb672
- · Replies 8 ·
- Introductory Physics Homework Help
- Replies
- 8