Author Topic: Removing zeros  (Read 1183 times)

0 Members and 1 Guest are viewing this topic.

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Removing zeros
« on: July 18, 2014, 05:13:32 pm »
Script core and server are developing, I cant use and find working scripts. Now I'm using vote with zeros (0.0000000)
One time I fixed but now I forgot how did I do that, I cant fix it, tried 15-20 times.
Code is here;
http://pastebin.com/5bdvdEfp
Is there anybody can write script?
Good, go and play soldat ^^

Offline Shoozza

  • Retired Soldat Developer
  • Veteran
  • ******
  • Posts: 1632
  • Soldat's Babysitter
    • Website
Re: Removing zeros
« Reply #1 on: July 19, 2014, 12:47:35 am »
I guess you want to format floating point output.

Try
FormatFloat('#.##', yourfloat)
or
Format('%.2f', [yourfloat]);
or
FloatToStrF(yourfloat, ffFixed, 4, 2));

They are explained here:
http://www.delphibasics.co.uk/RTL.asp?Name=FormatFloat
http://www.delphibasics.co.uk/RTL.asp?Name=FloatToStrF
http://www.delphibasics.co.uk/RTL.asp?Name=Format

Don't give up too early. Finding solutions on your own is a skill you have to build ;)
Rules
Tools: ARSSE - SARS - SRB - chatMod