Strings and Numbers - 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: Strings and Numbers (
/showthread.php?tid=240217)
Strings and Numbers -
deather - 15.03.2011
I have a long number, 674583948
I tried to use modifiers for variable but failed. When i tried to assign it directly to a variable
But it displayed some other number when i printed it. Then I tried to assign it to a string.
pawn Код:
new str[15];
format(str, 15, "674583948");
Then I tried to compare it with 777 and check if that number is equal using
pawn Код:
if(!strcmp(str, "777", true))
{
//blah blah code here....
}
But the comparison always returns 0 which makes it enter the if condition.
How do I compare the numbers?
Re: Strings and Numbers -
Voldemort - 15.03.2011
if(Number == OtherNumber)
{
}
Re: Strings and Numbers -
deather - 15.03.2011
Quote:
if(Number == OtherNumber)
{
}
|
The problem is I cant get the 'Number' parameter which is a long integer.
I had to pack it to a string, otherwise a long number is reduced to 2 digits. And strval is returning some other number (strval should and will return some other number. I know that).
Re: Strings and Numbers -
deather - 17.03.2011
This is how I fetch the line
pawn Код:
sscanf(fetchline, "p<|>ds[24]i", var[0], str[0], var[1]);
This is the Mysql Log:
Код:
CMySQLHandler::FetchRow() - Return: 364|DeaL|5587523124
This is how it prints the number:
pawn Код:
printf("%i", var[1]);
1292555828
Re: Strings and Numbers -
deather - 17.03.2011
Sorry, didnt know about the cell limit. So if my number is 558752312 will it work?
AW: Re: Strings and Numbers -
Nero_3D - 17.03.2011
Quote:
Originally Posted by deather
Sorry, didnt know about the cell limit. So if my number is 558752312 will it work?
|
Yes because it is between cellmin(-2^31) and cellmax (2^31 - 1)