Lord Kalthorn
Guru
- Messages
- 13,293
- Location
- Britain
Lol - I spent all of that time downstairs with sheets of paper trying to work it out! I went thorugh about 10 sheets;
First I tried to work out Decimal to Binary, and then a way to do it
for 5 to Binary (101)
5 / 2 2 rem 1
2 / 2 1 rem 0
1 / 2 0 rem 1
Backwards (this matters on other numbers) this is 101. And that works for all Binary Numbers. The Problem was that this is niether an equation nor anything like any kind of help programming it. I went through Logarithims - but I cannot remmember a thing about them (I'm only 16!) but i'm sure that would be a very good way to do it.
I'm sure thats the way you were trying to do it - but it doesn't help the 'how many times to divide?' question. Logarithims with a quick and easy Logging of the remander would sort this out - but I have no idea how to do it. This may help you!
However; I eventually gave up for today, and I will talk to my Maths teacher whom I am sure will know about Logarithims and then not only I will learn something about them but I can tell you if you haven't already worked it out by then. Decimal to Binary is not the easiest thing to do! even when you're just trying to find an equation let alone put it in code!
I felt bad about syaing that I would try my best to help you - and then not help you - so I went and found information on writing a Unicode to Binary Program:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdecimalclasschartodecimalconversiontopic.asp
This is single bit stuff - but it also has up to 64-bit stuff if you want it! It looks easy enough and I hope it can help you.
Hopefully I will be able to help you when I talk to my teacher about it - you don't get a degree in Maths without a great deal of knowledge about Logarithims! I will see what I can learn!
I hope that helped at least a bit - I'm sorry I couldn't find an equation!
First I tried to work out Decimal to Binary, and then a way to do it
for 5 to Binary (101)
5 / 2 2 rem 1
2 / 2 1 rem 0
1 / 2 0 rem 1
Backwards (this matters on other numbers) this is 101. And that works for all Binary Numbers. The Problem was that this is niether an equation nor anything like any kind of help programming it. I went through Logarithims - but I cannot remmember a thing about them (I'm only 16!) but i'm sure that would be a very good way to do it.
I'm sure thats the way you were trying to do it - but it doesn't help the 'how many times to divide?' question. Logarithims with a quick and easy Logging of the remander would sort this out - but I have no idea how to do it. This may help you!
However; I eventually gave up for today, and I will talk to my Maths teacher whom I am sure will know about Logarithims and then not only I will learn something about them but I can tell you if you haven't already worked it out by then. Decimal to Binary is not the easiest thing to do! even when you're just trying to find an equation let alone put it in code!
I felt bad about syaing that I would try my best to help you - and then not help you - so I went and found information on writing a Unicode to Binary Program:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdecimalclasschartodecimalconversiontopic.asp
This is single bit stuff - but it also has up to 64-bit stuff if you want it! It looks easy enough and I hope it can help you.
Hopefully I will be able to help you when I talk to my teacher about it - you don't get a degree in Maths without a great deal of knowledge about Logarithims! I will see what I can learn!
I hope that helped at least a bit - I'm sorry I couldn't find an equation!