Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- fixed bug # 19494

git-svn-id: http://svn.php.net/repository/pear/packages/Math_BigInteger/trunk@326530 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit f5ac56fee0fd2b59868a15774f3b8d787734d824 1 parent ca70b62
@terrafrost terrafrost authored
Showing with 23 additions and 18 deletions.
  1. +23 −18 BigInteger.php
View
41 BigInteger.php
@@ -47,26 +47,29 @@
* ?>
* </code>
*
- * LICENSE: This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
*
* @category Math
* @package Math_BigInteger
* @author Jim Wigginton <terrafrost@php.net>
* @copyright MMVI Jim Wigginton
- * @license http://www.gnu.org/licenses/lgpl.txt
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version $Id$
* @link http://pear.php.net/package/Math_BigInteger
*/
@@ -294,7 +297,9 @@ function Math_BigInteger($x = 0, $base = 10)
$this->value = array();
}
- if (empty($x)) {
+ // '0' counts as empty() but when the base is 256 '0' is equal to ord('0') or 48
+ // '0' is the only value like this per http://php.net/empty
+ if (empty($x) && (abs($base) != 256 || $x !== '0')) {
return;
}
@@ -2325,13 +2330,13 @@ function modInverse($n)
$one = new Math_BigInteger(1);
}
- // $x mod $n == $x mod -$n.
+ // $x mod -$n == $x mod $n.
$n = $n->abs();
if ($this->compare($zero) < 0) {
$temp = $this->abs();
$temp = $temp->modInverse($n);
- return $negated === false ? false : $this->_normalize($n->subtract($temp));
+ return $this->_normalize($n->subtract($temp));
}
extract($this->extendedGCD($n));
Please sign in to comment.
Something went wrong with that request. Please try again.