Get numbers after .
#3

2 ways I can think of.

1)
pawn Код:
new
    Float: a = 2555.140211,
    b[16],
    c;

format(b, sizeof b, "%f", a);
sscanf(b, "p<.>{i}i", c);
// c = 140211
You may have noticed {i} that the silent speficier that ignores the first integer before dot which is 2555 in our case. "p" specifier splits with delimiter (inside <delimiter_here>) which is dot.

sscanf is recommended.

2)
pawn Код:
new
    Float: a = 2555.140211,
    b[16],
    c;

a = floatfract(a); // a = 0.140211
format(b, sizeof b, "%f", a);
c = strval(b[2]);
// string b[2] is "140211"
// c = 140211
Reply


Messages In This Thread
Get numbers after . - by ScIrUsna - 03.06.2016, 11:05
Re: Get numbers after . - by F1N4L - 03.06.2016, 11:19
Re: Get numbers after . - by Konstantinos - 03.06.2016, 11:23
Re: Get numbers after . - by Vince - 03.06.2016, 14:21
Re: Get numbers after . - by Stinged - 03.06.2016, 15:45
Re: Get numbers after . - by Infinity - 03.06.2016, 16:00
Re: Get numbers after . - by Stinged - 03.06.2016, 16:01

Forum Jump:


Users browsing this thread: 1 Guest(s)