Professional Web Applications Themes

#39610 [NEW]: Number of return Modular_arithmetic is negative.. - PHP Bugs

From: ocracy at msn dot com Operating system: windows PHP version: 4.4.4 PHP Bug Type: *General Issues Bug description: Number of return Modular_arithmetic is negative.. Description: ------------ Number of return Modular_arithmetic must be positive in general but i tryed high nubmer like(2^30++) in Modular_arithmetic, PHP gave me negative nubmer... example: x=2^31, y=x%20, y = negative in PHP Reproduce code: --------------- <?php $number = 31; $pow = pow(2,$number); $random = rand(10,50); echo ($pow%$random); ?> Expected result: ---------------- Negative numbers.. Like -6 -38 -44 ... ... Actual result: -------------- nubmer of return will be positive.. -- Edit bug report at [url]http://bugs.php.net/?id=39610&edit=1[/url] -- ...

  1. #1

    Default #39610 [NEW]: Number of return Modular_arithmetic is negative..

    From: ocracy at msn dot com
    Operating system: windows
    PHP version: 4.4.4
    PHP Bug Type: *General Issues
    Bug description: Number of return Modular_arithmetic is negative..

    Description:
    ------------
    Number of return Modular_arithmetic must be positive in general but i
    tryed high nubmer like(2^30++) in Modular_arithmetic, PHP gave me
    negative nubmer...

    example: x=2^31, y=x%20, y = negative in PHP

    Reproduce code:
    ---------------
    <?php
    $number = 31;
    $pow = pow(2,$number);
    $random = rand(10,50);
    echo ($pow%$random);
    ?>

    Expected result:
    ----------------
    Negative numbers..
    Like
    -6
    -38
    -44
    ...
    ...

    Actual result:
    --------------
    nubmer of return will be positive..

    --
    Edit bug report at [url]http://bugs.php.net/?id=39610&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=39610&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=39610&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=39610&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=39610&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=39610&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=39610&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=39610&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=39610&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=39610&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=39610&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=39610&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=39610&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=39610&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=39610&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=39610&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=39610&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=39610&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=39610&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=39610&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=39610&r=mysqlcfg[/url]
    ocracy at msn dot com Guest

  2. #2

    Default #39610 [Opn->Bgs]: Number of return Modular_arithmetic is negative..

    ID: 39610
    Updated by: [email]tony2001php.net[/email]
    Reported By: ocracy at msn dot com
    -Status: Open
    +Status: Bogus
    Bug Type: *General Issues
    Operating System: windows
    PHP Version: 4.4.4
    New Comment:

    # php -r 'var_dump(pow(2,31));' is greater than PHP_INT_MAX, so it
    cannot be represented as positive integer when casted to int.
    Hence "Note: Remainder $a % $b is negative for negative $a."
    [url]http://www.php.net/manual/en/language.operators.arithmetic.php[/url]


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

    [2006-11-23 22:59:01] ocracy at msn dot com

    Description:
    ------------
    Number of return Modular_arithmetic must be positive in general but i
    tryed high nubmer like(2^30++) in Modular_arithmetic, PHP gave me
    negative nubmer...

    example: x=2^31, y=x%20, y = negative in PHP

    Reproduce code:
    ---------------
    <?php
    $number = 31;
    $pow = pow(2,$number);
    $random = rand(10,50);
    echo ($pow%$random);
    ?>

    Expected result:
    ----------------
    Negative numbers..
    Like
    -6
    -38
    -44
    ...
    ...

    Actual result:
    --------------
    nubmer of return will be positive..


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39610&edit=1[/url]
    tony2001@php.net Guest

  3. #3

    Default #39610 [Bgs]: Number of return Modular_arithmetic is negative..

    ID: 39610
    User updated by: ocracy at msn dot com
    Reported By: ocracy at msn dot com
    Status: Bogus
    Bug Type: *General Issues
    Operating System: windows
    PHP Version: 4.4.4
    New Comment:

    i beg your pardon.. i acted inattentive, i didnt pay attention to
    PHP_INT_MAX and nubmer of float


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

    [2006-11-23 23:11:17] [email]tony2001php.net[/email]

    # php -r 'var_dump(pow(2,31));' is greater than PHP_INT_MAX, so it
    cannot be represented as positive integer when casted to int.
    Hence "Note: Remainder $a % $b is negative for negative $a."
    [url]http://www.php.net/manual/en/language.operators.arithmetic.php[/url]

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

    [2006-11-23 22:59:01] ocracy at msn dot com

    Description:
    ------------
    Number of return Modular_arithmetic must be positive in general but i
    tryed high nubmer like(2^30++) in Modular_arithmetic, PHP gave me
    negative nubmer...

    example: x=2^31, y=x%20, y = negative in PHP

    Reproduce code:
    ---------------
    <?php
    $number = 31;
    $pow = pow(2,$number);
    $random = rand(10,50);
    echo ($pow%$random);
    ?>

    Expected result:
    ----------------
    Negative numbers..
    Like
    -6
    -38
    -44
    ...
    ...

    Actual result:
    --------------
    nubmer of return will be positive..


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=39610&edit=1[/url]
    ocracy at msn dot com Guest

Similar Threads

  1. Validate if form field entered by user is valid number(not a negative value)
    By design in progress in forum Coldfusion Database Access
    Replies: 2
    Last Post: May 24th, 07:06 AM
  2. Turning a negative number into a positive
    By Richard Atkins in forum Adobe Flash, Flex & Director
    Replies: 4
    Last Post: February 11th, 11:26 AM
  3. Return Line Number of text in a textfield?
    By anan in forum Macromedia Flash Actionscript
    Replies: 1
    Last Post: January 30th, 04:38 AM
  4. #25650 [Opn->Bgs]: Bad number return by % operator
    By pollita@php.net in forum PHP Development
    Replies: 0
    Last Post: September 25th, 02:17 PM
  5. #25650 [NEW]: Bad number return by % operator
    By jserrano at cutb dot edu dot co in forum PHP Development
    Replies: 0
    Last Post: September 25th, 06:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139