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: Round number to hundredths?

Previous Thread :: Next Thread 
Bobb1118 is not online. Bobb1118
Joined: 03 Oct 2008
Total Posts: 476
23 May 2013 12:25 PM
Value = 12.35654356
Value2 = 1.3421

want Value to = 12.37
and Value2 to = 1.34

how D:

since it could be variable length i cant use string sub
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
23 May 2013 12:44 PM
umm how would 12.35654356 round to 12.37?

function round2(x)
return math.floor(x*100+.5)/100
end

print(round2(12.35654356))

-> 12.36
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
23 May 2013 12:45 PM
Because, obeying the normal rules of Maths, the digit after the number you're rounding to has to increase by one if it's more than 5.
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
23 May 2013 12:47 PM
duh check the number again
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
23 May 2013 12:49 PM
12.35654356

12.356

Rounded to hundredths:

12.36
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
23 May 2013 12:50 PM
yes now read my post again
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
23 May 2013 12:50 PM
Oh.

Derp.

FloodCheck :l
Report Abuse
Bobb1118 is not online. Bobb1118
Joined: 03 Oct 2008
Total Posts: 476
23 May 2013 12:58 PM
yah i pushed the wrong key.
anyway i figured it out

math.floor(n * 10^p + .5)/10^p

n = number
p = number of places to show after decimal

now i have this issue

CurrentStat = Attack

Stats.Level.Text = [CurrentStat]..": "..[CurrentStat].MinLevel.Value.."/"..[CurrentStat].Level.Value

should read Attack: # / #

just keeps erroring "unexpected symbol near ["
Report Abuse
Bobb1118 is not online. Bobb1118
Joined: 03 Oct 2008
Total Posts: 476
23 May 2013 01:01 PM
again nevermind.

have to have a path beforhand
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