#20346 [Bgs]: Computation Error
| From: | derick@php.net | Date: | Sun, 10 Nov 2002 22:23:25 +0000 |
| Subject: | #20346 [Bgs]: Computation Error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-24459@lists.php.net to get a copy of this message | ||
ID: 20346
Updated by: derick@php.net
Reported By: sprice@wisc.edu
Status: Bogus
Bug Type: Math related
Operating System: Darwin 6.1 (Mac OS X.2.1)
PHP Version: 4CVS-2002-11-10
New Comment:
http://www.php.net/manual/en/print/language.types.float.php
Previous Comments:
------------------------------------------------------------------------
[2002-11-10 16:21:13] sprice@wisc.edu
Ummmm.... could you please explain why this isn't an error in PHP? It
is only simple math and PHP is giving me an incorrect result.
------------------------------------------------------------------------
[2002-11-10 15:48:16] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2002-11-10 15:44:44] sprice@wisc.edu
On this one, I really don't have a clue what is wrong with PHP. Run the
script shown below. Results should be "c" == "d" == "e", but
"e" is
some other value. I noticed that if you comment out the "$temp_x = ..."
line (which shouldn't matter anyway) you get the correct answer for
"e". I need this to convert a vector to unit length (which should be
simple enough) and I thought that I was going crazy.
If you want to see how PHP is configured, look here:
http://144.92.10.251/~sage/test.php
<?php
$temp_x = .0663;
$temp_y = .01486;
print "a=" . $temp_x . ", b=" . $temp_y . ", c=" .
(.0148 / sqrt( .0663 * .0663 + .01486 * .01486 ) ) . ", d=" .
($temp_y / sqrt( ( $temp_x * $temp_x ) + ( $temp_y * $temp_y ) ));
$temp_x = $temp_x / sqrt(($temp_x * $temp_x ) + ( $temp_y * $temp_y )
);
$temp_y = $temp_y / sqrt(($temp_x * $temp_x ) + ( $temp_y * $temp_y )
);
echo ", e=" . $temp_y;
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20346&edit=1