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 » Scripters
Home Search
 

Re: How can I make math.random have decimals?

Previous Thread :: Next Thread 
theninjaguy987 is not online. theninjaguy987
Joined: 21 Jun 2013
Total Posts: 766
23 Jul 2015 01:57 AM
Like if I had math.random(0.1,0.5) would it work? Or would I have to do something more advanced..?
Report Abuse
bosswalrus is not online. bosswalrus
Joined: 04 Jan 2013
Total Posts: 5430
23 Jul 2015 01:59 AM
http://www.roblox.com/Forum/ShowPost.aspx?PostID=159594866
Report Abuse
gooey333 is not online. gooey333
Joined: 24 Mar 2013
Total Posts: 1208
23 Jul 2015 02:16 AM
Yah, read post above... No other answer
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
23 Jul 2015 02:17 AM
math.random(5,10)/10;
Report Abuse
RegularTetragon is not online. RegularTetragon
Joined: 10 Oct 2009
Total Posts: 3085
23 Jul 2015 02:30 AM
math.random () returns a random number between 0 and 1 exclusive, therefore
math.random ()*(upperBound-lowerBound) + lowerBound
If the lower bound is always 0
math.random ()*upperBound

This gives very long decimals and is the "right" way of doing it, as in the most similar to other languages, most flexible kind of way. To get integers out, math.floor the output for [lower, upper) and math.ceil for (lower, upper]
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
23 Jul 2015 02:33 AM
"math.floor the output for [lower, upper) and math.ceil for (lower, upper]"

Or average with math.floor(num + 0.5)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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