ID:               48904
 Updated by:       j...@php.net
 Reported By:      7willows at dsl dot pipex dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Math related
 Operating System: SunOS ts10 5.11 snv_115 i86pc
 PHP Version:      5.2.10
 New Comment:

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

And we really mean it: Max. 10-20 lines of code should be enough to
reproduce this if it really is a bug..which I doubt.


Previous Comments:
------------------------------------------------------------------------

[2009-07-13 13:51:32] 7willows at dsl dot pipex dot com

Description:
------------
I have a function which is used to assign values into a number of
global arrays. Two of the arrays are assigned values that are generated
using the rand() function. A third array holds the result of the
multiplication. When both first two arrays are assigned a value of 0
(zero), the result of the multiplication is 1 and not 0.

This information is then entered into a html form and presented to the
user and they are asked to enter the results of 

$numfacttest[$a] / $randval[$a] = useranswer

The useranswer is then compared to $answer[$a] which is already
calculated. The problem is that 0 * 0 is returning the answer 1
sometimes.

Reproduce code:
---------------
function setnumberfacttest($count,$maxnumberfacts) {
   global $numfacttest, $answer, $operator, $randval;
   for ($a=0 ; $a < $count ; $a++) {
       $operator[a]=chr(247);
       $bit1=rand(0,$maxnumberfacts);
       $bit2=rand(0,$maxnumberfacts);
       $numfacttest[$a]=$bit1 * $bit2;
       $randval[$a]=$bit2;
       $answer[$a]=$bit1;
   }

}

Expected result:
----------------
Actual Results with hidden value displayed

2 / 1 = <useranswer> 2
0 / 0 = <useranswer> 0
0 / 0 = <useranswer> 0
2 / 2 = <useranswer> 1
4 / 2 = <useranswer> 2
1 / 1 = <useranswer> 1
0 / 0 = <useranswer> 0
0 / 0 = <useranswer> 0
0 / 0 = <useranswer> 0
1 / 1 = <useranswer> 1


Actual result:
--------------
Actual Results with calculated hidden value displayed

2 / 1 = <useranswer> 2
0 / 0 = <useranswer> 1
0 / 0 = <useranswer> 0
2 / 2 = <useranswer> 1
4 / 2 = <useranswer> 2
1 / 1 = <useranswer> 1
0 / 0 = <useranswer> 1
0 / 0 = <useranswer> 0
0 / 0 = <useranswer> 2
1 / 1 = <useranswer> 1



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48904&edit=1

Reply via email to