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
 

Numbers/Intigers

Previous Thread :: Next Thread 
kaddad14 is not online. kaddad14
Joined: 13 Apr 2013
Total Posts: 649
27 Jan 2017 03:55 PM
Any way to turn a decimal into an integer?
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
27 Jan 2017 03:56 PM
round it or just remove the decimal point?
you can just call math.floor() on it if the number is 5.000 or something like that


Report Abuse
UltimateRaheem is not online. UltimateRaheem
Joined: 10 Nov 2012
Total Posts: 1886
27 Jan 2017 03:57 PM
myFloat = 0.25;
math.floor(myFloat);

I think you can also do this, but that's Python:

myFloat = 0.25;
print(int(myFloat));


Want to be supported by developers in a positive atmosphere? Then join Studio BSD: roblox.com/My/Groups.aspx?gid=1013064
Report Abuse
DoNotReadThisNamePlz is not online. DoNotReadThisNamePlz
Joined: 01 Aug 2014
Total Posts: 679
27 Jan 2017 03:58 PM
roundedX = math.floor(0.5 + x)
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
27 Jan 2017 03:58 PM
Lua 5.1 doesn't have integers.


Report Abuse
kaddad14 is not online. kaddad14
Joined: 13 Apr 2013
Total Posts: 649
27 Jan 2017 04:08 PM
If I got a number like local x = ########### could I ## # =math.floor(x)
Report Abuse
kaddad14 is not online. kaddad14
Joined: 13 Apr 2013
Total Posts: 649
27 Jan 2017 04:18 PM
OH NO I SAID A DECIMAL!! How bad of me... anyway If I got a decimal like 4 . 5595959 could i do math.floor(x)?
Report Abuse
DoNotReadThisNamePlz is not online. DoNotReadThisNamePlz
Joined: 01 Aug 2014
Total Posts: 679
27 Jan 2017 04:19 PM
That'd round down ONLY.

To do a correct round, do math.floor(0.5+x)
Report Abuse
UltimateRaheem is not online. UltimateRaheem
Joined: 10 Nov 2012
Total Posts: 1886
27 Jan 2017 04:19 PM
math.floor rounds a float downwards to a whole number.
math.ceil rounds a float upwards to a whole number.

example:

math.floor(1.5); -- 1
math.ceil(1.5); -- 2


Want to be supported by developers in a positive atmosphere? Then join Studio BSD: roblox.com/My/Groups.aspx?gid=1013064
Report Abuse
kaddad14 is not online. kaddad14
Joined: 13 Apr 2013
Total Posts: 649
27 Jan 2017 04:35 PM
ok well how would I turn a number positive? (like x could be - or +)
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
27 Jan 2017 04:36 PM
math.abs()


Report Abuse
DoNotReadThisNamePlz is not online. DoNotReadThisNamePlz
Joined: 01 Aug 2014
Total Posts: 679
27 Jan 2017 04:36 PM
math.abs(x) will make sure the number is always positive (or 0 ;))
Report Abuse
kaddad14 is not online. kaddad14
Joined: 13 Apr 2013
Total Posts: 649
27 Jan 2017 04:37 PM
ty all
Report Abuse
UltimateRaheem is not online. UltimateRaheem
Joined: 10 Nov 2012
Total Posts: 1886
28 Jan 2017 07:23 AM
Thanks as well for making me understand absolute value


Want to be supported by developers in a positive atmosphere? Then join Studio BSD: roblox.com/My/Groups.aspx?gid=1013064
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