Float value
#1

I have a question
If I have a float (lets say for ex: 27.000),and I want to print only the 27 part? how can I do so?
for ex if I use %.2f that will print 27.00,and %.1f will print 27.0
I want it to print only 27.
How can I do it?
Thanks 4 helpers
nuriel
Reply
#2

pawn Код:
%.0f
Reply
#3

I hope this function is avalilable in C++ since it is everywhere.

new Float = 27000

while (x mod 10 = 0)
{
x=x div 10;
}

What it does? it does a loop with the condition if x is divided by 10, it should be integer as a result. If yes, divide by ten. And it goes.

1 check:
27 000 mod 10 = 0 //accuried
27 000 div 10 = 2700

2) 2700 mod 10 = 0
2700 div 10 = 270

3) 270 mod 10 = 0
270 div 10 = 27

4) 27 mod 0 != 0, there it's breaking, so x = 27.

Yeah, script's looks strange, but you can do with whatever number/float this which you want to convert in that way.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)