Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative integers are always encoded as INT8 #6

Open
laufhannes opened this issue Nov 2, 2018 · 0 comments
Open

Negative integers are always encoded as INT8 #6

laufhannes opened this issue Nov 2, 2018 · 0 comments

Comments

@laufhannes
Copy link

var_dump(UBJSON::decode(UBJSON::encode(-129)));
// out: int(127)

because of

php-ubjson/UBJSON.php

Lines 166 to 181 in 137001f

if (256 > $numeric) {
$swap = false;
if (0 < $numeric) {
$result = self::UINT8;
$pack = 'C';
} else {
$result = self::INT8;
$pack = 'c';
}
} elseif (32768 > $numeric) {
$result = self::INT16;
$pack = 's';
} elseif (2147483648 > $numeric) {
$result = self::INT32;
$pack = 'l';
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant