PDA

View Full Version : [Q] Difference beetween %d and %i


scott1
16/09/2012, 02:27 PM
I all,

as the title say :D

Thank you

Max

ThomasCarter
16/09/2012, 02:28 PM
%d Is For Numbers And %s Is To Announce a Name Or Item, ILl find out %i cause ive never used that one

Seven_of_Nine
16/09/2012, 02:29 PM
for example:
%d - doube: 2.1 or 23.5
%i - integer: 32 or 49

C00K13M0N$73R
16/09/2012, 02:43 PM
for example:
%d - doube: 2.1 or 23.5
%i - integer: 32 or 49
%d + %i - both integer.

Your thing of a float, %f

Babul
16/09/2012, 02:46 PM
%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 :)

scott1
16/09/2012, 02:46 PM
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

scottyishere
16/09/2012, 02:47 PM
So, there isn't a big difference,

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

Max

yes.

Babul
16/09/2012, 02:49 PM
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.

AtItsMax
16/09/2012, 02:53 PM
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 if you want to format a string with %i or %d, then you may use any variant.

Sinner
16/09/2012, 03:09 PM
d = decimal
i = integer

Both do the same.