SA-MP Forums Archive
[Q] Difference beetween %d and %i - 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)
+--- Thread: [Q] Difference beetween %d and %i (/showthread.php?tid=378099)



[Q] Difference beetween %d and %i - scott1 - 16.09.2012

I all,

as the title say

Thank you

Max


Re: [Q] Difference beetween %d and %i - ThomasCarter - 16.09.2012

%d Is For Numbers And %s Is To Announce a Name Or Item, ILl find out %i cause ive never used that one


Re: [Q] Difference beetween %d and %i - Seven_of_Nine - 16.09.2012

for example:
%d - doube: 2.1 or 23.5
%i - integer: 32 or 49


Re: [Q] Difference beetween %d and %i - C00K13M0N$73R - 16.09.2012

Quote:
Originally Posted by Seven_of_Nine
Посмотреть сообщение
for example:
%d - doube: 2.1 or 23.5
%i - integer: 32 or 49
%d + %i - both integer.

Your thing of a float, %f


Re: [Q] Difference beetween %d and %i - Babul - 16.09.2012

%d and %i are identical - assuming you reference to the sscanf2 plugin - both variants scan for a (decimal) integer, signed or not. i prefer %d however, its usage is common practise.
edit: argh, next time i will refresh b4 posting - good to know that there are 2 wrong and 2 true answers now. chose wisely


Re : [Q] Difference beetween %d and %i - scott1 - 16.09.2012

So, there isn't a big difference,

i can use %i tho show 500000 as i can use %d ?

Sometimes my sql request bug,

format(query, sizeof(query), "UPDATE `"db_bizs"` SET Price=%i WHERE ID=%d",30000,1);

and it update the price of the biz 1 to 0.

So i ask it could become from the %i

Max


Re: Re : [Q] Difference beetween %d and %i - scottyishere - 16.09.2012

Quote:
Originally Posted by scott1
Посмотреть сообщение
So, there isn't a big difference,

i can use %i tho show 500000 as i can use %d ?

Max
yes.


Re: [Q] Difference beetween %d and %i - Babul - 16.09.2012

yes, if you want to format a string with %i or %d, then you may use any variant.
any (negative) number (roughly) ranging from -2000000000 upto 2000000000 will work.


Re: [Q] Difference beetween %d and %i - AtItsMax - 16.09.2012

I use them both for the same thing and never found any problem because they both are integars (can be used for integars) but as Babul stated above
Quote:

if you want to format a string with %i or %d, then you may use any variant.




Re: [Q] Difference beetween %d and %i - Sinner - 16.09.2012

d = decimal
i = integer

Both do the same.