By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,642 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,642 IT Pros & Developers. It's quick & easy.

Using math functions in PHP 4.3.5

P: n/a
I have upgraded PHP on our server (a RedHat 7.2 box) to version 4.3.5.
However,
now code I wrote in PHP before fails to work correctly. I have some
code that invokes the math function atan2 in connection with
converting rectangular to polar coordinates in a Web page. This used
to work in PHP 4.x (earlier version) but failed with 4.3.4 and now
with 4.3.5. I haven't found anything in the README files about this
-- any thoughts on how to make atan2 work?
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 8 Apr 2004 17:22:48 -0700, bs********@ucok.edu (Bill Stockwell) wrote:
I have upgraded PHP on our server (a RedHat 7.2 box) to version 4.3.5.
However,
now code I wrote in PHP before fails to work correctly. I have some
code that invokes the math function atan2 in connection with
converting rectangular to polar coordinates in a Web page. This used
to work in PHP 4.x (earlier version) but failed with 4.3.4 and now
with 4.3.5. I haven't found anything in the README files about this
-- any thoughts on how to make atan2 work?


Failed in what way?

atan2 works fine for me on PHP 4.3.5, and I've not specified anything special
with regards to maths modules.

Configure Command
'./configure' '--prefix=/usr' '--with-apxs2=/usr/apache2/bin/apxs'
'--with-config-file-path=/etc/apache2' '--enable-trans-sid' '--with-gd'
'--with-mysql=/usr/mysql' '--with-zlib-dir=/usr' '--with-jpeg'
'--with-jpeg-dir=/usr'

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #2

P: n/a
Andy Hassall <an**@andyh.co.uk> wrote in message news:<71********************************@4ax.com>. ..
On 8 Apr 2004 17:22:48 -0700, bs********@ucok.edu (Bill Stockwell) wrote:
I have upgraded PHP on our server (a RedHat 7.2 box) to version 4.3.5.
However,
now code I wrote in PHP before fails to work correctly. I have some
code that invokes the math function atan2 in connection with
converting rectangular to polar coordinates in a Web page. This used
to work in PHP 4.x (earlier version) but failed with 4.3.4 and now
with 4.3.5. I haven't found anything in the README files about this
-- any thoughts on how to make atan2 work?


Failed in what way?

atan2 works fine for me on PHP 4.3.5, and I've not specified anything special
with regards to maths modules.

Configure Command
'./configure' '--prefix=/usr' '--with-apxs2=/usr/apache2/bin/apxs'
'--with-config-file-path=/etc/apache2' '--enable-trans-sid' '--with-gd'
'--with-mysql=/usr/mysql' '--with-zlib-dir=/usr' '--with-jpeg'
'--with-jpeg-dir=/usr'

It fails in that no matter what (x,y) point I give it, I get 0 back
for the angle. This did NOT happen with PHP 4.0.6 -- it worked just
fine then.
Jul 17 '05 #3

P: n/a
On 9 Apr 2004 06:57:15 -0700, bs********@ucok.edu (Bill Stockwell) wrote:
Andy Hassall <an**@andyh.co.uk> wrote in message news:<71********************************@4ax.com>. ..
On 8 Apr 2004 17:22:48 -0700, bs********@ucok.edu (Bill Stockwell) wrote:
>I have upgraded PHP on our server (a RedHat 7.2 box) to version 4.3.5.
> However,
>now code I wrote in PHP before fails to work correctly. I have some
>code that invokes the math function atan2 in connection with
>converting rectangular to polar coordinates in a Web page. This used
>to work in PHP 4.x (earlier version) but failed with 4.3.4 and now
>with 4.3.5. I haven't found anything in the README files about this
>-- any thoughts on how to make atan2 work?


Failed in what way?

atan2 works fine for me on PHP 4.3.5, and I've not specified anything special
with regards to maths modules.

Configure Command
'./configure' '--prefix=/usr' '--with-apxs2=/usr/apache2/bin/apxs'
'--with-config-file-path=/etc/apache2' '--enable-trans-sid' '--with-gd'
'--with-mysql=/usr/mysql' '--with-zlib-dir=/usr' '--with-jpeg'
'--with-jpeg-dir=/usr'


It fails in that no matter what (x,y) point I give it, I get 0 back
for the angle. This did NOT happen with PHP 4.0.6 -- it worked just
fine then.


Output of this script on PHP 4.3.5:

<pre>
<?php
$xrange = 3;
$yrange = 3;

print " ";
for ($x=-$xrange; $x<=$xrange; $x++)
printf(" %-6d", $x);

echo "\n";

for ($y=-$yrange; $y<=$yrange; $y++)
{
printf(" %-6d ", $y);

for ($x=-$xrange; $x<=$xrange; $x++)
{
printf(" %-3.3f", atan2($x, $y));
}
echo "\n";
}

?>
</pre>

Is:
-3 -2 -1 0 1 2 3
-3 -2.356 -2.554 -2.820 3.142 2.820 2.554 2.356
-2 -2.159 -2.356 -2.678 3.142 2.678 2.356 2.159
-1 -1.893 -2.034 -2.356 3.142 2.356 2.034 1.893
0 -1.571 -1.571 -1.571 0.000 1.571 1.571 1.571
1 -1.249 -1.107 -0.785 0.000 0.785 1.107 1.249
2 -0.983 -0.785 -0.464 0.000 0.464 0.785 0.983
3 -0.785 -0.588 -0.322 0.000 0.322 0.588 0.785

Which looks right to me.

So does this give all zeroes on your setup?

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.