how do I get more numbers past the decimal?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
I've got a script giving me these numbers:

6.63929118396

7.05473398749

7.12985593724

6.88449562182

6.91296700337

7.2069019927

7.16478639215

7.40497984532

7.3106818645

6.71419045446

6.37627234293

6.28909001856

6.44524429616

6.83769742038

6.89069889014

7.19938492851

7.17217812206

7.41825566619

7.33051737792

7.53219459913

7.40100023245

6.77411901206

6.41129621789

6.3044317688

I'm worried that PHP is rounding these numbers off. How can I ask it
to give me more numbers past the decimal?

Re: how do I get more numbers past the decimal?

Jake Barnes wrote:

>
<snip>

http://www.php.net/manual/en/language.types.float.php

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: how do I get more numbers past the decimal?

[snip -- was it really necessary to give so many?]

Just curious... Why do you want more? What application is this, for which 12
significant digits of precision is *insufficient* ??

Re: how do I get more numbers past the decimal?

Doug Miller wrote:

Rocket science, probably...

Re: how do I get more numbers past the decimal?

On Aug 1, 9:27=A0am, spamb...@milmac.com (Doug Miller) wrote:

I'm sorry, I should have been more clear. Just recently I started
getting interested in chaos. I can't say why, really, I've just
recently found the subject interesting. And I read that Lorenz was
able to simulate a chaotic system with as little as 3 non-linear
equations. My math is pretty weak, so I looked this stuff up online
and started playing around with it, using a simple PHP script to
experiment. And then I started wondering, am I getting the full
number, or is PHP shortening this?

Re: how do I get more numbers past the decimal?

Jake Barnes wrote:

If the number is irrational, then no computer or language will EVER give
you the "full number".

Re: how do I get more numbers past the decimal?

<sheldonlg> wrote:

[...]

For that matter, most *rational* numbers cannot be precisely expressed in a
computer, either.

Re: how do I get more numbers past the decimal?

On Aug 1, 6:08 pm, sheldonlg <sheldonlg> wrote:

numbers:

Right, true. In terms of what is valid or meaningful, in terms of
precision, when I'm playing around with some of the equations that
I've looked up, I've questions that I'll post to forums devoted to
math. But, aside from the math questions, I thought a more basic
question was simply about the mechanical aspects of what I'm doing -
that is, am I getting reliable numbers, should I be using PHP or
something else, etc.

Re: how do I get more numbers past the decimal?

Jake Barnes wrote:

Oh dear, I simulated the n body problem, which doesn't even need non
linear equations. even a 3 body problem is hopelessly unstable.

And yes, you do need precisions so that the merest butterfly is recorded
as well as the mass of the universe. However consider the lack of
precision just 'random noise'

ISTR it was in fact truncation errors that first led to the
investigation of serious sensitivity in equation solutions, known as
chaos theory..

Re: how do I get more numbers past the decimal?

Jake Barnes schrob:

\$number=chr(rand(48,57)).".";
for (\$i=0;\$i<200;\$i++) \$number.=chr(rand(48,57));

*SCNR*
--
Gruß | Greetings | Qapla'
Die Liebe zur Schule wächst mit dem Quadrat der Entfernung!

Re: how do I get more numbers past the decimal?

Frank Steinmetzger wrote:

How does this give higher precision for the number?  You're generating
multiple random digits.

I didn't see anywhere where he stated this was a random number.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: how do I get more numbers past the decimal?

Jerry Stuckle wrote:

But he didn't specify that it wasn't either.

I guess subtle humour isn't your bag..

Re: how do I get more numbers past the decimal?

Jerry Stuckle schreef:

http://www.internetslang.com/SCNR.asp

--
Luuk

Re: how do I get more numbers past the decimal?

Luuk wrote:

I KNOW what it means.  But too many programmers could take this seriously.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: how do I get more numbers past the decimal?

Jerry Stuckle schreef:

than my reply was not ment for you, but for 'too many programmers'....

;-)

--
Luuk

Re: how do I get more numbers past the decimal?

Jerry Stuckle wrote:

Only ones with your sort of low IQ humourless background.

Re: how do I get more numbers past the decimal?

Jerry Stuckle schreef:

http://www.internetslang.com/SCNR.asp

--
Luuk

Re: how do I get more numbers past the decimal?

Jake Barnes wrote:

<snip>

How are you getting even that many?  A floating point number is stored
on a 32 bit machine using the 24 bit for the mantissa and its sign and 8
bits for the exponent and its sign.  That means that the largest number
that can be in the matissa is 2**23 or about 8,000,000.  That means
seven significant digits.  You are showing 12 significant digits.  Are
you working on a 64 bit machine?

Re: how do I get more numbers past the decimal?

sheldonlg wrote:

Actually it is more like this.

(32-bit float)

3         2         1
10987654321098765432109876543210
-   1-bit sign (1 == negative)
--------   8-bit exponent (unsigned)
24-bit mant   ------------------------

Given a normalized floating point number, the high order bit (msb) of
the 24-bit mantissa (b23) is always 1. Knowing this we use the bit to
store the lsb of the exponent. Largest mantissa is 2**24-1. 16,777,215.

A float value can be exactly represented by up to 9 decimal digits.

The largest positive value representable in a float looks like:

01111111 01111111 11111111 11111111
Exp = 254 (128)
10000000
Man =   .11111111 11111111 11111111
3.40282347e+38

--
Joe Wright
"Memory is the second thing to go. I forget what the first is."

Re: how do I get more numbers past the decimal?

Joe Wright wrote:

Almost correct - except that the exponent can also be signed - 7 digits
plus the sign.

However, this is only accurate for binary32 format (32 bits of binary
number).  Other formats (binary64, etc.) have different precision.

Additionally, there is no indication that the PHP script is generating
the numbers.  They could very easily be coming from outside of the script.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================