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 » Roblox » Suggestions & Ideas
Home Search
 

Re: math.round()

Previous Thread :: Next Thread 
Qorm is not online. Qorm
Joined: 25 Jul 2010
Total Posts: 1650
15 May 2015 07:55 PM
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round


just make life easier
Report Abuse
TheSilverWaters is not online. TheSilverWaters
Joined: 01 Nov 2011
Total Posts: 1362
15 May 2015 08:08 PM
support. I'm too lazy to type a few lines of code for a process as simple as rounding :P

I'd like to use

math.round(1.5)

to return the number 2
Report Abuse
Qorm is not online. Qorm
Joined: 25 Jul 2010
Total Posts: 1650
15 May 2015 10:15 PM
math.round() would be 100x easier and it requires 12 characters and may be more efficient
Report Abuse
TheForumingForumer2 is not online. TheForumingForumer2
Joined: 12 Apr 2015
Total Posts: 1461
15 May 2015 11:06 PM
sure why not





the second one
Report Abuse
wonderful72pike is not online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
15 May 2015 11:09 PM
I know an even shorter one:

math.ceil()

And the other one, which is the same length:

math.floor()

It allows you more choice over how you want numbers rounded, which can be a big deal if your game uses a lot of decimal-integer conversions.
Report Abuse
DoAnAileronRoll is not online. DoAnAileronRoll
Joined: 08 Feb 2015
Total Posts: 5360
15 May 2015 11:09 PM
just make a modulescript library, and have an argument with the number you want to round or something I don't know


can't you just put your macroed code down somewhere
copy
paste
replace x with numbers
done?
Report Abuse
TheForumingForumer2 is not online. TheForumingForumer2
Joined: 12 Apr 2015
Total Posts: 1461
15 May 2015 11:10 PM
well yeah but

what if you want to just round to the nearest integer and not just up or down?

we would still be able to use math.ceil()
and math.floor()



the second one
Report Abuse
Qorm is not online. Qorm
Joined: 25 Jul 2010
Total Posts: 1650
16 May 2015 09:31 AM
math.floor() goes down... math.ceil() goes up... math.round() will go either way!
Report Abuse
ArcticSorcery is not online. ArcticSorcery
Joined: 19 Aug 2009
Total Posts: 4761
16 May 2015 09:37 AM
math.ceil(x - 0.5)
Report Abuse
DoAnAileronRoll is not online. DoAnAileronRoll
Joined: 08 Feb 2015
Total Posts: 5360
16 May 2015 11:24 PM
*facepalm*


that requires editing of the lua coding language itself


if you REALLY want to do that

bother Brazil about it
Report Abuse
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
16 May 2015 11:51 PM
sure
but why would you need to round

Save the plants! Plants > animals!
Report Abuse
Qorm is not online. Qorm
Joined: 25 Jul 2010
Total Posts: 1650
17 May 2015 10:23 AM
a gui that indicates someones health by % or by number text for example
Report Abuse
sonihi is online. sonihi
Joined: 27 Jun 2009
Total Posts: 3655
17 May 2015 10:27 AM
function round(n)
if n-math.floor(n)<0.5 then
return math.floor(n)
end
else return math.ceil(n)
end

A rounding function!
Report Abuse
Qorm is not online. Qorm
Joined: 25 Jul 2010
Total Posts: 1650
17 May 2015 11:00 AM
math.round(n)
Report Abuse
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
17 May 2015 12:57 PM
"
a gui that indicates someones health by % or by number text for example"
*facepalm*
make the gui 300 px long
then subtract 3 for every 1 health gone

Save the plants! Plants > animals!
Report Abuse
Qorm is not online. Qorm
Joined: 25 Jul 2010
Total Posts: 1650
17 May 2015 01:29 PM
@above
WTF?
*facepalm* this is what you do ok

frame=script.Parent:findFirstChild("Frame")
frame.Size=UDim2.new(1,0,1,0) --100%...
while true and wait() do
--ok, pretend like the frame is inside another frame which indicates the health by %
frame.Size.Scale=frame.Size.Scale/frame.Parent.Size.Scale*100 --this is how you get a %
end

also, input should be like this if your health is, lets say 43/125: 34.4%, lets round that up using the inexistent math.round now..

frame.Size.Scale=math.round(frame.Size.Scale/frame.Parent.Size.Scale*100) and the health shall be 43/125, so since math.round is there it will automatically be rounded up to 34; 34%

your welcome for the tip and explanation
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Roblox » Suggestions & Ideas
   
 
   
  • 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