Decimal/bits converter

If you have problems installing or running Algodoo, have found a bug or need in-game help - this is it!

Decimal/bits converter

Postby Matten » Sun Dec 18, 2011 8:45 pm

Is there a formula to get the number of bits needed to make a certain amount of numbers? So 2 will give 1, 4 will give 2, 8 will give 3 etc
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
User avatar
Matten
 
Posts: 435
Joined: Mon Apr 05, 2010 2:03 pm
Location: The Netherlands

Re: Decimal/bits converter

Postby monstertje3 » Sun Dec 18, 2011 9:11 pm

in binary i dont think 8 will result in 3, it is more likely it will have 0001 as output;
Code: Select all
2^0,2^1,2^2,2^3
0   0   0   1
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
User avatar
monstertje3
 
Posts: 343
Joined: Sat Sep 05, 2009 4:29 pm
Location: N-H, NL

Re: Decimal/bits converter

Postby Matten » Sun Dec 18, 2011 9:21 pm

I don't mean a binary number, but the number of bits. With 3 bits there are 2^3 = 8 possible combinations, with 4 bits there are 2^4 = 16 possible combinations etc... But I want the reverse, so how many bits do you need to get 8 or 16 possible combinations.

I also like your sig
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
User avatar
Matten
 
Posts: 435
Joined: Mon Apr 05, 2010 2:03 pm
Location: The Netherlands

Re: Decimal/bits converter

Postby Ivan » Sun Dec 18, 2011 10:11 pm

You can do this via logarithms.

2ˣ = Y
X = log(Y)
User avatar
Ivan
 
Posts: 203
Joined: Tue Oct 06, 2009 2:01 pm
Location: Croatia

Re: Decimal/bits converter

Postby Matten » Sun Dec 18, 2011 11:21 pm

Thanks! I tested it with some graphing app, but does Algodoo know the log2 function? I thought I've seen the log function somewhere, but not log2.
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
User avatar
Matten
 
Posts: 435
Joined: Mon Apr 05, 2010 2:03 pm
Location: The Netherlands

Re: Decimal/bits converter

Postby monstertje3 » Mon Dec 19, 2011 8:25 am

log2 is the same as log Y / log 2
if i am understanding that log2(Y) 2logY is
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
User avatar
monstertje3
 
Posts: 343
Joined: Sat Sep 05, 2009 4:29 pm
Location: N-H, NL

Re: Decimal/bits converter

Postby Matten » Mon Dec 19, 2011 4:23 pm

Log(y)/log(2) nearly crashed that app...
I'll start my comp now to try it in Algodoo, and otherwise I suggest adding a logN(base,power) function

Edit: I searched for "log" in the console, but that also doesn't give any logarithm related stuff. Anyone any ideas?
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
User avatar
Matten
 
Posts: 435
Joined: Mon Apr 05, 2010 2:03 pm
Location: The Netherlands

Re: Decimal/bits converter

Postby monstertje3 » Mon Dec 19, 2011 6:50 pm

according to the functions list in the thyme section, there isn't a log function :(
maybe make a suggestion in the suggestion forum
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
User avatar
monstertje3
 
Posts: 343
Joined: Sat Sep 05, 2009 4:29 pm
Location: N-H, NL

Re: Decimal/bits converter

Postby emilk » Tue Dec 20, 2011 1:36 pm

No need, I'll add Math.log (natural base) and Math.log10 (nice to have) in next version.
Emil Ernerfeldt, lead developer
emilk
 
Posts: 616
Joined: Mon Aug 31, 2009 11:01 am
Location: Umeå, Sweden


Return to Help / Bug reports

Who is online

Users browsing this forum: No registered users and 6 guests