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

View File

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