Crash when using %b in format with negative number - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Crash when using %b in format with negative number (
/showthread.php?tid=153903)
Crash when using %b in format with negative number -
ziomal432 - 11.06.2010
I've got this function:
Код:
stock decbin(number)
{
new binary_string[35];
format(binary_string, 35, "%b", number);
return binary_string;
}
but it crashes when I do:
Код:
print(decbin(-5372));
It should print
Код:
11111111111111111110101100000100
(got it from PHP's decbin function).
Also, with %x - it shows something strange.
Код:
print(dechex(-53733535));
Код:
stock dechex(number)
{
new hexadecimal_string[15];
format(hexadecimal_string, 15, "%x", number);
return hexadecimal_string;
}