Page 1 of 1

PHP and numbers problem

Posted: Mon Apr 18, 2005 6:28 am
by Calimero
Situation is as follows:

I have number 10, and I want it 20 times to multiply it self and after each time it does so, to write the result on the page.


After some time(s) it does not output plain "100000000000000000000" format but "1.E+20".

This comes to me as a big problem because of this code:

Code: Select all

$the_number_above = /* ex. */ 100000000000000000000

echo $slice_the_end = substr( $the_number_above, -2 );
Outputs: "20" as an integer - it outputs the value of the exponent, and that is what I don't need - anyone has an idea how to beat this problem.


My question is how to instruct ( or prevent ) php to present in this way.

Been looking in the php.ini and httpd.conf, no luck.

PHP 5, Apache 1.23.xx ( I think - for apache ).


Thanks Ahead !

Posted: Mon Apr 18, 2005 7:41 am
by feyd
that "number" is too large for integers in php. You need to get big number support... but why do you need it?

Your number is converted to a double, which is a floating point system. It's no longer an integer by that point.

...

Posted: Mon Apr 18, 2005 7:45 am
by Calimero
I need some system that uses numbers as co-ordinates ( or reference )
so I need to preserve the exact structure of the number.

I was thinking to use STRING for echo-ing but the number I have to preserve in order to apply mathematical calculations.

Any ideas - ways to do this - is it possible?

Posted: Mon Apr 18, 2005 7:51 am
by feyd
unless your coordinate system has trillions of units in dimensions on screen at once, use a "multiplier". That's how games have done it for many many years. The "current multiplier" tells the system where to translate all coordinates from a given point of arrangement in space.

...

Posted: Mon Apr 18, 2005 10:05 am
by Calimero
Don't quite follow - can you explain this a bit.

If possibly ( and if it is short ) on some minor example.

Posted: Mon Apr 18, 2005 7:28 pm
by feyd
transform the extradimensional information into local space.