Xampp / PHP inconsistent float calculations

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Xampp / PHP inconsistent float calculations

Postby jokko » 17. September 2010 13:52

First off - excellent package :D

I have recently installed Xampp 1.7.3 on a new Windows 7 laptop to continue working on a php project (well trying to learn php actually).
I am trying to do some calculations of a few floats but sometimes the calculation produce the wrong results, either text or 0.0000000000.

For example I have the following code.

Code: Select all
$total = $diff->y * 365.25;


$diff is a DateInterval object, this calculation is carried out 6 times in a loop, 2 out of 6 times the result = 0.0000000000.

exactly the same for

Code: Select all
$total = ceil($period);


This happens every time, I have tried var_dump and the type is correct.

Any help appreciated.
Regards
Mark
jokko
 
Posts: 3
Joined: 17. September 2010 13:36

Re: Xampp / PHP inconsistent float calculations

Postby jokko » 24. September 2010 14:04

I have copied the the xampp folder to a windows xp virtual machine to see if windows 7 is the cause.

And it seems to work fine under windows xp, but not on my laptop running windows 7 Enterprise.

Any advice on how to get it running correctly on my host?
I have tried setting the power management on my laptop to performace and disabled cpu throttling - same results.

Float calculation sometimes return with ascii? for example the number 10 returns as ''i' even when the type is float.

Regards
Mark.
jokko
 
Posts: 3
Joined: 17. September 2010 13:36

Re: Xampp / PHP inconsistent float calculations

Postby JonB » 24. September 2010 22:40

64 Bit Win 7?

if 64bit
-- AMD or Intel CPU?

-- How much memory?

-- Where is XAMPP installed?

endif

In my fact-checking, I did see notes about PHP floating point fudges that don't return expected results (I Googled PHP floating point errors)

You might change your PHP error reporting (its off by default, AFAIK) to see if PHP is actually warning you.

I'd also prowl the PHP forums on this one.

Good Luck, I'll be very curious to know the answers here.

8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Xampp / PHP inconsistent float calculations

Postby jokko » 27. September 2010 14:11

32bit Windows 7 Enterprise.

Core 2 DUO P8700
4Gb ram

Installed in the default c:\xampp.

I did google PHP floating point issues, but everything I found was to do with how PHP stores a floating point numbers and how you may getting rounding errors.
I have just checked my php.ini and these are the settings.

Code: Select all
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
display_errors = On


I have just changed them to

Code: Select all
error_reporting = E_ALL & E_NOTICE & E_DEPRECATED
display_errors = On


No errors, but how strange I cannot recreate what was happening before, every calc is working ok on the host. I have been using the vm since I had the problems so didn't really delve into it while is wasn't working.

I really don't know what could have caused it, I will use windows 7 again now hopefully until I run into this probem again and I can investigate further.

The only thing I could think of would be cpu throttling / scaling and other power management settings affecting php?

Anyway, thanks for advice.
I will post back if I encounter the problem again.

Regards
Mark
jokko
 
Posts: 3
Joined: 17. September 2010 13:36


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 179 guests