1
0
mirror of https://github.com/danog/PHPStruct.git synced 2024-11-26 19:54:38 +01:00

Fixed precision problem in decbin function

This commit is contained in:
danogentili 2016-08-14 19:51:41 +02:00
parent de4894e5c9
commit ceabe3f4f7
2 changed files with 19 additions and 17 deletions

27
composer.lock generated
View File

@ -1208,16 +1208,16 @@
},
{
"name": "symfony/yaml",
"version": "v3.1.2",
"version": "v3.1.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de"
"reference": "1819adf2066880c7967df7180f4f662b6f0567ac"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/2884c26ce4c1d61aebf423a8b912950fe7c764de",
"reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de",
"url": "https://api.github.com/repos/symfony/yaml/zipball/1819adf2066880c7967df7180f4f662b6f0567ac",
"reference": "1819adf2066880c7967df7180f4f662b6f0567ac",
"shasum": ""
},
"require": {
@ -1253,32 +1253,33 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2016-06-29 05:41:56"
"time": "2016-07-17 14:02:08"
},
{
"name": "webmozart/assert",
"version": "1.0.2",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/assert.git",
"reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde"
"reference": "bb2d123231c095735130cc8f6d31385a44c7b308"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde",
"reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde",
"url": "https://api.github.com/repos/webmozart/assert/zipball/bb2d123231c095735130cc8f6d31385a44c7b308",
"reference": "bb2d123231c095735130cc8f6d31385a44c7b308",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
"php": "^5.3.3|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.6"
"phpunit/phpunit": "^4.6",
"sebastian/version": "^1.0.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "1.2-dev"
}
},
"autoload": {
@ -1302,7 +1303,7 @@
"check",
"validate"
],
"time": "2015-08-24 13:29:44"
"time": "2016-08-09 15:02:57"
}
],
"aliases": [],

View File

@ -685,10 +685,11 @@ class StructTools
} else {
$negative = false;
}
do {
$concat = $this->posmod($number, 2).$concat;
$number = intval($number / 2);
} while ($number > 0);
while ($number > 0) {
$curchar = $this->posmod($number, 2);
$concat = $curchar.$concat;
$number = (($number - $curchar) / 2);
}
$concat = str_pad($concat, $length, '0', STR_PAD_LEFT);
if ($negative) {
$concat = $this->binadd($this->stringnot($concat), '1');