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: Finding out the celing of the power of the base a number is?

Previous Thread :: Next Thread 
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
25 Sep 2011 06:17 PM
Title is kinda hard to understand.

Let's say I have 95346. In base 10, I want a function that returns 5.
If I had 30, for base 2, I'd want a function that returns 5 as well.

Would I have to make some logarithm function for every base? D:
Report Abuse
WeDoItForTheLulz is not online. WeDoItForTheLulz
Joined: 14 Sep 2011
Total Posts: 28
25 Sep 2011 06:19 PM
I would go out and buy a Magic eight ball.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
25 Sep 2011 06:24 PM
"Would I have to make some logarithm function for every base? D:"

You could make the function for ONE base and make another function that converts any number from any base to any base and use that.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
25 Sep 2011 06:25 PM
why convert to bases when you can use one number? silly.
Report Abuse
WeDoItForTheLulz is not online. WeDoItForTheLulz
Joined: 14 Sep 2011
Total Posts: 28
25 Sep 2011 06:32 PM
:o
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
25 Sep 2011 06:33 PM
"why convert to bases when you can use one number? silly."

idk. You said you might have to make a function for each base. I suggested to just convert to bases instead.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
25 Sep 2011 06:34 PM
ikr

I made a place value getter that works for any number in any base without conversion or strings or all that crap.
Report Abuse
WeDoItForTheLulz is not online. WeDoItForTheLulz
Joined: 14 Sep 2011
Total Posts: 28
25 Sep 2011 06:38 PM
Blocco swore :o
Report Abuse
Aaaboy97 is not online. Aaaboy97
Joined: 05 Apr 2009
Total Posts: 6612
25 Sep 2011 06:39 PM
    local function power(a, b)
        local c = b
        local d = 0
        while b < a do
            b = c^d
            d = d + 1
        end
        return d - 1
    end

    print(power(30, 2), power(95346, 10))
    > 5 5
Report Abuse
WeDoItForTheLulz is not online. WeDoItForTheLulz
Joined: 14 Sep 2011
Total Posts: 28
25 Sep 2011 06:39 PM
Aaaboy97 :O
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
25 Sep 2011 06:40 PM
@WeDoItForTheLulz

I don't see how that's swearing.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
25 Sep 2011 06:40 PM
Aaaboy, srsly, lrn2giveacomprehensiblenametourvariablesplz
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
25 Sep 2011 06:41 PM
You're asking for the floor of a log in a given base...?

math.floor(1+ math.log( n ) / math.log(b) )


?

Report Abuse
Aaaboy97 is not online. Aaaboy97
Joined: 05 Apr 2009
Total Posts: 6612
25 Sep 2011 06:42 PM
Julien, srsly, stoptrollingformackerel
Report Abuse
Aaaboy97 is not online. Aaaboy97
Joined: 05 Apr 2009
Total Posts: 6612
25 Sep 2011 06:42 PM
@BlueTaslem

That's much better than mine, because i have no idea how to use log >.<
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
25 Sep 2011 06:43 PM
I'm not trolling...?!?!?

Seriously, giving letter names to your variables makes it look.. so ugly.. ;o
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
25 Sep 2011 06:45 PM
Simple rules for logs.
(You'll need to know them eventually:)

a*log b = log(b^a)
log[a] b / log[a] c = log[c] b

Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
25 Sep 2011 10:25 PM
I don't understand how

math.log( n ) / math.log( b ) == x in b^x
Report Abuse
eyeontheprizeREBOOT is not online. eyeontheprizeREBOOT
Joined: 30 Jan 2011
Total Posts: 1555
25 Sep 2011 10:27 PM
log( n ) / log( 2 ) == log2( n )
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
25 Sep 2011 10:28 PM
But I don't understand how that works.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
25 Sep 2011 10:29 PM
log( n ) / log( 2 ) == b^(n-2)?
Report Abuse
eyeontheprizeREBOOT is not online. eyeontheprizeREBOOT
Joined: 30 Jan 2011
Total Posts: 1555
25 Sep 2011 10:29 PM
magic smoke stored in your cpu
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
25 Sep 2011 10:30 PM
I simple do not understand what makes it return a value related to the one in the base you want.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
25 Sep 2011 10:31 PM
I'm not fit for being a scripter. I am ashamed.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
25 Sep 2011 10:35 PM
This would be a perfect time for HotThoth to save the day. *COUGH* HOTTHOTH *COUGH*
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