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

**posted on**

- Jake Barnes

August 1, 2009, 7:43 am

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?

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?

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..

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?

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

==================

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?

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

seven significant digits. You are showing 12 significant digits. Are

you working on a 64 bit machine?

<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 meansseven 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?

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

==================

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

==================

#### Site Timeline

- » Create an image - thumbnail on the fly
- — Next thread in » PHP Scripting Forum

- » super substr()?
- — Previous thread in » PHP Scripting Forum

- » URL redirection
- — Newest thread in » PHP Scripting Forum

- » Seamless SSO
- — Last Updated thread in » PHP Scripting Forum

- » Dell Battery Slice LED codes
- — The site's Newest Thread. Posted in » Laptop Computers Forum