From a83cf553f998f3f7c7bbca185bf27847cff22fc0 Mon Sep 17 00:00:00 2001 From: kotyara Date: Thu, 15 Sep 2022 22:28:36 +0500 Subject: [PATCH] fix --- src/utils/Utils.php | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/utils/Utils.php b/src/utils/Utils.php index 80499b6e..7d70a65b 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -644,27 +644,28 @@ class Utils{ public static function writeLong($value){ $x = ""; - if(strval($value[0] == null ? '' : $value[0]) === "-"){ - $negative = true; - $value = bcadd($value, "1"); - if(strval($value[0]) === "-"){ - $value = substr($value, 1); - } - }else{ - $negative = false; - } - while(bccomp($value, "0", 0) > 0){ - $temp = bcmod($value, "16777216"); - $x = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $x; - $value = bcdiv($value, "16777216", 0); - } - $x = str_pad(substr($x, 0, 8), 8, "\x00", STR_PAD_LEFT); - if($negative === true){ - $x = ~$x; - } - return $x; + if(!is_float($value)){ + if(strval($value[0] == null ? '' : $value[0]) === "-"){ + $negative = true; + $value = bcadd($value, "1"); + if(strval($value[0]) === "-"){ + $value = substr($value, 1); + } + }else{ + $negative = false; + } + while(bccomp($value, "0", 0) > 0){ + $temp = bcmod($value, "16777216"); + $x = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $x; + $value = bcdiv($value, "16777216", 0); + } + $x = str_pad(substr($x, 0, 8), 8, "\x00", STR_PAD_LEFT); + if($negative === true){ + $x = ~$x; + } + return $x; + } } - } //if(Utils::isOnline() === false){