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 to get percentages of numbers?

Previous Thread :: Next Thread 
K7Q is not online. K7Q
Joined: 23 Mar 2013
Total Posts: 5546
06 Aug 2015 01:49 PM
lets say i have a number

like what math do i have to do to see what the percent of 52 into 1017 is?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 Aug 2015 01:50 PM
1017*.52


This is basic primary math...
Report Abuse
FIares is not online. FIares
Joined: 07 Nov 2010
Total Posts: 641
06 Aug 2015 01:50 PM
(52/1017) * 100


Check out my in-game scripting tutorial! [ 279086510 ]
Report Abuse
K7Q is not online. K7Q
Joined: 23 Mar 2013
Total Posts: 5546
06 Aug 2015 01:50 PM
i was wondering what was the most efficient for scripting?
Report Abuse
Robertoman is not online. Robertoman
Joined: 10 May 2007
Total Posts: 6369
06 Aug 2015 01:52 PM
Multiply by fraction
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
06 Aug 2015 01:52 PM
new rule: you must complete 3rd grade to post here
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
06 Aug 2015 01:52 PM
Most efficient? What? A simple calculator would laugh at such a simple math problem.
Report Abuse
K7Q is not online. K7Q
Joined: 23 Mar 2013
Total Posts: 5546
06 Aug 2015 01:54 PM
no i meant as in like which would cause the least amount of lag because a lot of math problems solved at once makes lag.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 Aug 2015 01:57 PM
^


No but seriously this way is the most efficient:

1017*.52


It only takes 1 operation, plus there's no dividing, and dividing is more expensive than multiplication.
Report Abuse
Robertoman is not online. Robertoman
Joined: 10 May 2007
Total Posts: 6369
06 Aug 2015 01:57 PM
Multiply by a fraction
Report Abuse
Robertoman is not online. Robertoman
Joined: 10 May 2007
Total Posts: 6369
06 Aug 2015 01:59 PM
Number=100

Number=number*.5-->half of number

print(Number)
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
06 Aug 2015 01:59 PM
the amount of lag that a simple math problem will cause is so insignificant
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 Aug 2015 02:00 PM
That ^ was meant for rayk999 qq

Dividing can be up to 2x (or more) expensive than multiplication, so my way probably is best since it's most compact.
Report Abuse
K7Q is not online. K7Q
Joined: 23 Mar 2013
Total Posts: 5546
06 Aug 2015 02:01 PM
@warspy

1017 * .52 gives me 500 something so at the end I still have to divide by 100
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
06 Aug 2015 02:04 PM
The question is a bit misleading

Do you mean 52/1017 transformed into a percentage?
Or what 52% of 1017 is?
Report Abuse
Robertoman is not online. Robertoman
Joined: 10 May 2007
Total Posts: 6369
06 Aug 2015 02:05 PM
I feel nub, lol typo...

Number=100

Number=Number*.5-->half of number

print(Number)
-->50
--Congrats 50% == .5 learn to convert percentage to decimal
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 Aug 2015 02:05 PM
t = tick()
for i = 1, 10000 do
local ans = 100*i
end
print(tick()-t)

t = tick()
for i = 1, 10000 do
local ans = 100/i
end
print(tick()-t)



>0.00050687789916992
>0.00057220458984375





See :D
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 Aug 2015 02:07 PM
> print(1017 * 0.52)
528.84



Looks like it's working to me.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 Aug 2015 02:10 PM
Lemme show you the diff between the 2 methods:


t = tick()
for i = 1, 10 do
for i = 0, 1, 0.001 do
local ans = 100*i
end
end
print(tick()-t)

t = tick()
for i = 1, 10 do
for i = 0, 1, 0.001 do
local ans = i/100*100
end
end
print(tick()-t)


> 0.00049972534179688 --This was my method
> 0.00084543228149414 --This was the divide then multiply method
Report Abuse
Robertoman is not online. Robertoman
Joined: 10 May 2007
Total Posts: 6369
06 Aug 2015 02:10 PM
If you are wanting to know the percentage is of 53 into 1017 is, then:

1017/52
-->19.56%
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
06 Aug 2015 02:11 PM
That's because you're performing two different operations.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 Aug 2015 02:12 PM
@nQ I know, that's the different between the 2 methods.


However even alone division is longer than multiplication, but by very little.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
06 Aug 2015 02:14 PM
When using the brackets it's even longer:


> t = tick()
for i = 1, 10 do
for i = 0, 1, 0.001 do
local ans = 100*i
end
end
print(tick()-t)

t = tick()
for i = 1, 10 do
for i = 0, 1, 0.001 do
local ans = i/100*100
end
end
print(tick()-t)

t = tick()
for i = 1, 10 do
for i = 0, 1, 0.001 do
local ans = (i/100)*100
end
end
print(tick()-t)
> 0.00052499771118164
> 0.00084543228149414
> 0.00084686279296875
Report Abuse
K7Q is not online. K7Q
Joined: 23 Mar 2013
Total Posts: 5546
06 Aug 2015 02:16 PM
nvm already got it
Report Abuse
Robertoman is not online. Robertoman
Joined: 10 May 2007
Total Posts: 6369
06 Aug 2015 02:22 PM
Wow sorry, I'm tired Flares was correct, the answer is

52/1017*100

-->5.11%


I'm going to bed, been scripting for to long today. Later.
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