php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20346 Computation Error
Submitted: 2002-11-10 15:44 UTC Modified: 2002-11-10 16:54 UTC
From: sprice at wisc dot edu Assigned:
Status: Not a bug Package: Math related
PHP Version: 4CVS-2002-11-10 OS: Darwin 6.1 (Mac OS X.2.1)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sprice at wisc dot edu
New email:
PHP Version: OS:

 

 [2002-11-10 15:44 UTC] sprice at wisc dot 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;
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-10 15:48 UTC] 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 16:21 UTC] sprice at wisc dot 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 16:54 UTC] sprice at wisc dot edu
Nope, it isn't a precision problem, it is a regular old PEKAC error or ID 10 T error. Sorry for bothering you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC