Crash when using %b in format with negative number
#1

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;
}
Quote:

[15:02:55] ---"('!

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)