Double values mathematical functions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anilva
Forum Newbie
Posts: 3
Joined: Mon Aug 05, 2002 7:28 am
Location: Singapore

Double values mathematical functions

Post by anilva »

I am having problems with the mathematical functions of php. I need to manipulate double precision numbers and I am using bcmath library. But when the number becomes smaller like 0.0001, I am not able to get the results for even addition.

Anybody knows what will be the problem? I set the scale to 30. Also, how can I display these numbers in scientific format like 1.0E-4 etc?

Thanks.
User avatar
haagen
Forum Commoner
Posts: 79
Joined: Thu Jul 11, 2002 3:57 pm
Location: Sweden, Lund

Post by haagen »

I can be wrong here, but isn't this configurable in your php.ini file?
anilva
Forum Newbie
Posts: 3
Joined: Mon Aug 05, 2002 7:28 am
Location: Singapore

Post by anilva »

I haven't completely resolved the problem. But there is lot more improvement now. Let me explain my application. I've some data in a mysql database. The values that I'm using for calculation is of type double in the database. I retrieve the data using PHP and do some complex calcuations before presenting to the user.
Once I retrieve the data, I cast them into double as well. Precision setting in my PHP.INI is 14. In order to get this kind of precision, I used bcmath library to do the calculations. But, if the values are too small, output of my bcmath functions are 0.
Now, I set the precision of my PHP.INI to 5 and changed all the bcmath functions to normal calculations. I choose 5 as the data presentation is with the maximum of 5 decimal points. Now, I need not to do any formating for presenting the data, It looks fine. Any way, I am still having problems with comparision of small numbers. Trying to resolve it now.
Post Reply