Hi everybody,
i'm struggling a little bit with following problem of binary conversion
2 have to convert two numbers into an binary value to concatenate both 8 bit binaries to a 16 bit binary.
like this: 219 = 11011011 and 7 = 00000111, now i must concatenate both to 0000011111011011
after doing that, the 0000011111011011 must converted to a number, ( = 2011.)
Unfortunately i can't find any to/from binary conversion in the conversion library ( or i do oversee something )
any advice very appreciated!
best regards
number to binary
Re: number to binary
Hi,uhrmacher wrote:Hi everybody,
i'm struggling a little bit with following problem of binary conversion
2 have to convert two numbers into an binary value to concatenate both 8 bit binaries to a 16 bit binary.
like this: 219 = 11011011 and 7 = 00000111, now i must concatenate both to 0000011111011011
after doing that, the 0000011111011011 must converted to a number, ( = 2011.)
Unfortunately i can't find any to/from binary conversion in the conversion library ( or i do oversee something )
any advice very appreciated!
best regards
All numbers are already represented in binary inside variables, so you won't find functions to convert a numerical value into binary...
What you will find are routines to convert variable contents into human readable strings (e.g. strings that show the decimal representation or the hexadecimal one, or even the binary one) and vice versa.
So, the only thing that can be answered here is:
You can do this with:now i must concatenate both
Code: Select all
hi(wordvar) = var2 'the 7 in your example
lo(wordvar) = var1 'the 219 in your example
Maybe this article can also be of some interest: http://www.rosseeld.be/DRO/PIC/Numbers% ... Pascal.htm (also valid for mikroBasic, but other code syntax).
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)