generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Decimals...

Previous Thread :: Next Thread 
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
11 Sep 2011 08:14 AM
I have a decimal such as 4.8384737
How can I round it to 4.8 in Lua?

~A revolution is born when one forgets the meaning of "impossible"
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
11 Sep 2011 08:17 AM
decimal = 4.8384737 * 10
round = math.ceil(decimal)
round = round / 10
print(round)

>4.8

Maybe?

~A revolution is born when one forgets the meaning of "impossible"
Report Abuse
sycips is not online. sycips
Joined: 21 Mar 2011
Total Posts: 1368
11 Sep 2011 08:20 AM
you can do that with this:

you number is like 9.6478325.

string.format(%.1f, 9.6478325)

output will be: 9.6! try for yourself.

%.1f means 1 decimal
%.2f means 2 decimal
%.3f means 3 decimal ect.

ok?
Report Abuse
RATEXmegaGAMER is not online. RATEXmegaGAMER
Joined: 10 Dec 2010
Total Posts: 4046
11 Sep 2011 08:39 AM
Any of you ever heard of math.floor()?
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
11 Sep 2011 08:42 AM
@RATE
math.ceil rounds up, and math.floor rounds down.

~A revolution is born when one forgets the meaning of "impossible"
Report Abuse
RATEXmegaGAMER is not online. RATEXmegaGAMER
Joined: 10 Dec 2010
Total Posts: 4046
11 Sep 2011 08:43 AM
I know and in your case you use math.floor
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
11 Sep 2011 08:44 AM
It doesn't much matter.

~A revolution is born when one forgets the meaning of "impossible"
Report Abuse
sycips is not online. sycips
Joined: 21 Mar 2011
Total Posts: 1368
11 Sep 2011 08:50 AM
lol
Report Abuse
sycips is not online. sycips
Joined: 21 Mar 2011
Total Posts: 1368
11 Sep 2011 08:55 AM
btw math.ceil and math.floor rounds with zero decimals string.format will round in decimals...
Report Abuse
sycips is not online. sycips
Joined: 21 Mar 2011
Total Posts: 1368
11 Sep 2011 09:00 AM
srry again because string.format was something I didn't read at the roblox wiki and it doesn't work on roblox -_-" so srry can't help you...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image