FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=16734&edit=1

ID: 16734
Updated by: terrafrost@php.net
Reported By: wizardhorizon at gmail dot com
Summary: Can't generate expected value.
Status: Open
Type: Bug
Package: Math_BigInteger
Operating System: FreeBSD
Package Version: 1.0.0RC3
PHP Version: 5.2.3
Roadmap Versions:
New Comment:

You're experiencing the problem on 5.2.3 but not on 5.3.0?

I downloaded 5.2.3 from http://museum.php.net/php5/ and was unable to
reproduce the problem. I tried it with all three modes, too, without
success:

<?php
require_once('BigInteger.php');
//define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
//define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);

$i = 0;
do {
$i++;
$tmp = new Math_BigInteger($i);
}while($tmp->toString() == "0");

echo $i;
?>


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

[2009-10-24 07:26:11] white_crow

Description:
------------
The bag I found is not to generate expected numerical value if the
value is less than 65536 (0x10000).

I also try running Test Script on PHP5.3.0 + Apache2.2.13 +
Ubuntu9.04.
But this package(Big_Integer) works without any problem.

Thank you for your reading my bad English.

Test script:
---------------
<?php
require_once('Math/BigInteger.php');

$i = 0;
do {
$i++;
$tmp = new Math_BigInteger($i);
}while($tmp->toString() == "0");

echo $i;

?>

Expected result:
----------------
1

Actual result:
--------------
65536

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

Search Discussions

  • Wizardhorizon at Oct 24, 2009 at 6:19 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=16734&edit=1

    ID: 16734
    Updated by: wizardhorizon@gmail.com
    Reported By: wizardhorizon at gmail dot com
    Summary: Can't generate expected value.
    Status: Open
    Type: Bug
    Package: Math_BigInteger
    Operating System: FreeBSD
    Package Version: 1.0.0RC3
    PHP Version: 5.2.3
    Roadmap Versions:
    New Comment:

    I appreciate your replying me quickly.

    The problem happens on PHP5.2.3.
    The environment's phpinfo() is http://erde.clover.vc/phpinfo.php

    There are Test script on http://erde.clover.vc/big_int/test_bigint.php

    I tried finding the reason why the problem happens.
    I think that there is a factor which cause the problem on
    _base256_rshift().

    I changed in BigInteger.php on line 246 to 249.
    --------- Original Code ---------
    case MATH_BIGINTEGER_MODE_INTERNAL:

    while (strlen($x)) {

    $this->value[] =
    $this->_bytes2int($this->_base256_rshift($x, 26));

    }

    --------- Changed Code ---------
    case MATH_BIGINTEGER_MODE_INTERNAL:
    print("x:".$x."\n");

    while (strlen($x)) {

    $this->value[] =
    $this->_bytes2int($this->_base256_rshift($x, 26));
    print($this->value[key($this->value)]."\n");

    }
    print_r($this->value);
    print("\n");

    And I ran Test script with changed BigInteger.php;
    <?php
    require_once('Math/BigInteger.php');
    $test = new Math_BigInteger(5);
    ?>

    Expected result:
    ----------------
    x: // 0005
    5
    Array ( [0] => 5 )

    Actual result:
    --------------
    x: // 0005

    Array ( [0] => 0 )


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

    [2009-10-24 16:43:54] terrafrost

    You're experiencing the problem on 5.2.3 but not on 5.3.0?

    I downloaded 5.2.3 from http://museum.php.net/php5/ and was unable to
    reproduce the problem. I tried it with all three modes, too, without
    success:

    <?php
    require_once('BigInteger.php');
    //define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
    //define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);

    $i = 0;
    do {
    $i++;
    $tmp = new Math_BigInteger($i);
    }while($tmp->toString() == "0");

    echo $i;
    ?>

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

    [2009-10-24 07:26:11] white_crow

    Description:
    ------------
    The bag I found is not to generate expected numerical value if the
    value is less than 65536 (0x10000).

    I also try running Test Script on PHP5.3.0 + Apache2.2.13 +
    Ubuntu9.04.
    But this package(Big_Integer) works without any problem.

    Thank you for your reading my bad English.

    Test script:
    ---------------
    <?php
    require_once('Math/BigInteger.php');

    $i = 0;
    do {
    $i++;
    $tmp = new Math_BigInteger($i);
    }while($tmp->toString() == "0");

    echo $i;

    ?>

    Expected result:
    ----------------
    1

    Actual result:
    --------------
    65536

    ------------------------------------------------------------------------
  • Terrafrost at Oct 24, 2009 at 11:06 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=16734&edit=1

    ID: 16734
    Updated by: terrafrost@php.net
    Reported By: wizardhorizon at gmail dot com
    Summary: Can't generate expected value.
    Status: Open
    Type: Bug
    Package: Math_BigInteger
    Operating System: FreeBSD
    Package Version: 1.0.0RC3
    PHP Version: 5.2.3
    Roadmap Versions:
    New Comment:

    Would you be willing to maybe grant me FTP access? If so, email me the
    info - don't post it here. If not, debugging this will be a bit more
    time consuming for both of us, but it'll still be do'able.


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

    [2009-10-24 20:18:42] white_crow

    I appreciate your replying me quickly.

    The problem happens on PHP5.2.3.
    The environment's phpinfo() is http://erde.clover.vc/phpinfo.php

    There are Test script on http://erde.clover.vc/big_int/test_bigint.php

    I tried finding the reason why the problem happens.
    I think that there is a factor which cause the problem on
    _base256_rshift().

    I changed in BigInteger.php on line 246 to 249.
    --------- Original Code ---------
    case MATH_BIGINTEGER_MODE_INTERNAL:

    while (strlen($x)) {

    $this->value[] =
    $this->_bytes2int($this->_base256_rshift($x, 26));

    }

    --------- Changed Code ---------
    case MATH_BIGINTEGER_MODE_INTERNAL:
    print("x:".$x."\n");

    while (strlen($x)) {

    $this->value[] =
    $this->_bytes2int($this->_base256_rshift($x, 26));
    print($this->value[key($this->value)]."\n");

    }
    print_r($this->value);
    print("\n");

    And I ran Test script with changed BigInteger.php;
    <?php
    require_once('Math/BigInteger.php');
    $test = new Math_BigInteger(5);
    ?>

    Expected result:
    ----------------
    x: // 0005
    5
    Array ( [0] => 5 )

    Actual result:
    --------------
    x: // 0005

    Array ( [0] => 0 )

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

    [2009-10-24 16:43:54] terrafrost

    You're experiencing the problem on 5.2.3 but not on 5.3.0?

    I downloaded 5.2.3 from http://museum.php.net/php5/ and was unable to
    reproduce the problem. I tried it with all three modes, too, without
    success:

    <?php
    require_once('BigInteger.php');
    //define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
    //define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);

    $i = 0;
    do {
    $i++;
    $tmp = new Math_BigInteger($i);
    }while($tmp->toString() == "0");

    echo $i;
    ?>

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

    [2009-10-24 07:26:11] white_crow

    Description:
    ------------
    The bag I found is not to generate expected numerical value if the
    value is less than 65536 (0x10000).

    I also try running Test Script on PHP5.3.0 + Apache2.2.13 +
    Ubuntu9.04.
    But this package(Big_Integer) works without any problem.

    Thank you for your reading my bad English.

    Test script:
    ---------------
    <?php
    require_once('Math/BigInteger.php');

    $i = 0;
    do {
    $i++;
    $tmp = new Math_BigInteger($i);
    }while($tmp->toString() == "0");

    echo $i;

    ?>

    Expected result:
    ----------------
    1

    Actual result:
    --------------
    65536

    ------------------------------------------------------------------------
  • Wizardhorizon at Oct 25, 2009 at 2:05 am
    Edit report at http://pear.php.net/bugs/bug.php?id=16734&edit=1

    ID: 16734
    Updated by: wizardhorizon@gmail.com
    Reported By: wizardhorizon at gmail dot com
    Summary: Can't generate expected value.
    Status: Open
    Type: Bug
    Package: Math_BigInteger
    Operating System: FreeBSD
    Package Version: 1.0.0RC3
    PHP Version: 5.2.3
    Roadmap Versions:
    New Comment:

    OK. I trust you.
    My email address is wizardhorizon@gmail.com.
    I'll send you email which is about FTP access with this address.


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

    [2009-10-25 01:05:59] terrafrost

    Would you be willing to maybe grant me FTP access? If so, email me the
    info - don't post it here. If not, debugging this will be a bit more
    time consuming for both of us, but it'll still be do'able.

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

    [2009-10-24 20:18:42] white_crow

    I appreciate your replying me quickly.

    The problem happens on PHP5.2.3.
    The environment's phpinfo() is http://erde.clover.vc/phpinfo.php

    There are Test script on http://erde.clover.vc/big_int/test_bigint.php

    I tried finding the reason why the problem happens.
    I think that there is a factor which cause the problem on
    _base256_rshift().

    I changed in BigInteger.php on line 246 to 249.
    --------- Original Code ---------
    case MATH_BIGINTEGER_MODE_INTERNAL:

    while (strlen($x)) {

    $this->value[] =
    $this->_bytes2int($this->_base256_rshift($x, 26));

    }

    --------- Changed Code ---------
    case MATH_BIGINTEGER_MODE_INTERNAL:
    print("x:".$x."\n");

    while (strlen($x)) {

    $this->value[] =
    $this->_bytes2int($this->_base256_rshift($x, 26));
    print($this->value[key($this->value)]."\n");

    }
    print_r($this->value);
    print("\n");

    And I ran Test script with changed BigInteger.php;
    <?php
    require_once('Math/BigInteger.php');
    $test = new Math_BigInteger(5);
    ?>

    Expected result:
    ----------------
    x: // 0005
    5
    Array ( [0] => 5 )

    Actual result:
    --------------
    x: // 0005

    Array ( [0] => 0 )

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

    [2009-10-24 16:43:54] terrafrost

    You're experiencing the problem on 5.2.3 but not on 5.3.0?

    I downloaded 5.2.3 from http://museum.php.net/php5/ and was unable to
    reproduce the problem. I tried it with all three modes, too, without
    success:

    <?php
    require_once('BigInteger.php');
    //define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
    //define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);

    $i = 0;
    do {
    $i++;
    $tmp = new Math_BigInteger($i);
    }while($tmp->toString() == "0");

    echo $i;
    ?>

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

    [2009-10-24 07:26:11] white_crow

    Description:
    ------------
    The bag I found is not to generate expected numerical value if the
    value is less than 65536 (0x10000).

    I also try running Test Script on PHP5.3.0 + Apache2.2.13 +
    Ubuntu9.04.
    But this package(Big_Integer) works without any problem.

    Thank you for your reading my bad English.

    Test script:
    ---------------
    <?php
    require_once('Math/BigInteger.php');

    $i = 0;
    do {
    $i++;
    $tmp = new Math_BigInteger($i);
    }while($tmp->toString() == "0");

    echo $i;

    ?>

    Expected result:
    ----------------
    1

    Actual result:
    --------------
    65536

    ------------------------------------------------------------------------
  • Terrafrost at Oct 25, 2009 at 3:26 am
    Edit report at http://pear.php.net/bugs/bug.php?id=16734&edit=1

    ID: 16734
    Updated by: terrafrost@php.net
    Reported By: wizardhorizon at gmail dot com
    Summary: Can't generate expected value.
    -Status: Open
    +Status: Closed
    Type: Bug
    Package: Math_BigInteger
    Operating System: FreeBSD
    Package Version: 1.0.0RC3
    PHP Version: 5.2.3
    -Assigned To:
    +Assigned To: terrafrost
    Roadmap Versions:
    New Comment:

    -Status: Open
    +Status: Closed
    -Assigned To:
    +Assigned To: terrafrost
    This bug has been fixed in SVN.

    If this was a documentation problem, the fix will appear on
    pear.php.net by the end of next Sunday (CET).

    If this was a problem with the pear.php.net website, the change should
    be live shortly.

    Otherwise, the fix will appear in the package's next release.

    Thank you for the report and for helping us make PEAR better.

    I upgraded you to the latest SVN and it's working now. I should have
    thought about that as a possible solution before asking you for FTP
    access... sorry about that.


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

    [2009-10-25 03:05:29] white_crow

    OK. I trust you.
    My email address is wizardhorizon@gmail.com.
    I'll send you email which is about FTP access with this address.

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

    [2009-10-25 01:05:59] terrafrost

    Would you be willing to maybe grant me FTP access? If so, email me the
    info - don't post it here. If not, debugging this will be a bit more
    time consuming for both of us, but it'll still be do'able.

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

    [2009-10-24 20:18:42] white_crow

    I appreciate your replying me quickly.

    The problem happens on PHP5.2.3.
    The environment's phpinfo() is http://erde.clover.vc/phpinfo.php

    There are Test script on http://erde.clover.vc/big_int/test_bigint.php

    I tried finding the reason why the problem happens.
    I think that there is a factor which cause the problem on
    _base256_rshift().

    I changed in BigInteger.php on line 246 to 249.
    --------- Original Code ---------
    case MATH_BIGINTEGER_MODE_INTERNAL:

    while (strlen($x)) {

    $this->value[] =
    $this->_bytes2int($this->_base256_rshift($x, 26));

    }

    --------- Changed Code ---------
    case MATH_BIGINTEGER_MODE_INTERNAL:
    print("x:".$x."\n");

    while (strlen($x)) {

    $this->value[] =
    $this->_bytes2int($this->_base256_rshift($x, 26));
    print($this->value[key($this->value)]."\n");

    }
    print_r($this->value);
    print("\n");

    And I ran Test script with changed BigInteger.php;
    <?php
    require_once('Math/BigInteger.php');
    $test = new Math_BigInteger(5);
    ?>

    Expected result:
    ----------------
    x: // 0005
    5
    Array ( [0] => 5 )

    Actual result:
    --------------
    x: // 0005

    Array ( [0] => 0 )

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

    [2009-10-24 16:43:54] terrafrost

    You're experiencing the problem on 5.2.3 but not on 5.3.0?

    I downloaded 5.2.3 from http://museum.php.net/php5/ and was unable to
    reproduce the problem. I tried it with all three modes, too, without
    success:

    <?php
    require_once('BigInteger.php');
    //define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
    //define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);

    $i = 0;
    do {
    $i++;
    $tmp = new Math_BigInteger($i);
    }while($tmp->toString() == "0");

    echo $i;
    ?>

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

    [2009-10-24 07:26:11] white_crow

    Description:
    ------------
    The bag I found is not to generate expected numerical value if the
    value is less than 65536 (0x10000).

    I also try running Test Script on PHP5.3.0 + Apache2.2.13 +
    Ubuntu9.04.
    But this package(Big_Integer) works without any problem.

    Thank you for your reading my bad English.

    Test script:
    ---------------
    <?php
    require_once('Math/BigInteger.php');

    $i = 0;
    do {
    $i++;
    $tmp = new Math_BigInteger($i);
    }while($tmp->toString() == "0");

    echo $i;

    ?>

    Expected result:
    ----------------
    1

    Actual result:
    --------------
    65536

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedOct 24, '09 at 2:44p
activeOct 25, '09 at 3:26a
posts5
users2
websitepear.php.net

2 users in discussion

Terrafrost: 3 posts Wizardhorizon: 2 posts

People

Translate

site design / logo © 2022 Grokbase