Converting binary to decimal in a program
Hello,
Hi, I have a BS2 and I'm wondering if there is a command or something that
will convert an 8-bit binary number into decimal form? I'm familiar with
the calculations for manually figuring out the equivalent form, but I'm
sure there has to be a better way of converting without coding in all the
lines of code that would take. I want to use this decimal number within the
program to compare two light values from my a/d convertor / phototransistor
setup, so the debug modifier doesn't work for me in this case. Is it
possible to use the dec modifier for debug in another way to just convert
my binary number into decimal?
Thanks,
Mike, aka Flaming Headphones
ICQ: 17940917
E-mail: headphones99@i...
Hi, I have a BS2 and I'm wondering if there is a command or something that
will convert an 8-bit binary number into decimal form? I'm familiar with
the calculations for manually figuring out the equivalent form, but I'm
sure there has to be a better way of converting without coding in all the
lines of code that would take. I want to use this decimal number within the
program to compare two light values from my a/d convertor / phototransistor
setup, so the debug modifier doesn't work for me in this case. Is it
possible to use the dec modifier for debug in another way to just convert
my binary number into decimal?
Thanks,
Mike, aka Flaming Headphones
ICQ: 17940917
E-mail: headphones99@i...
Comments
>Hello,
>Hi, I have a BS2 and I'm wondering if there is a command or something that
>will convert an 8-bit binary number into decimal form? I'm familiar with
>the calculations for manually figuring out the equivalent form, but I'm
>sure there has to be a better way of converting without coding in all the
>lines of code that would take. I want to use this decimal number within
>the program to compare two light values from my a/d convertor /
>phototransistor setup, so the debug modifier doesn't work for me in this
>case. Is it possible to use the dec modifier for debug in another way to
>just convert my binary number into decimal?
Debug CAN use modifiers. Check Page 253 of the Version 1.9 PBASIC Manual.
>Thanks,
>Mike, aka Flaming Headphones
>
>
>ICQ: 17940917
>E-mail: headphones99@i...
x var byte (variable that will be read as decimal)
x.bit0 = y.bit? (LSB of your binary number)
x.bit1 = y.bit?
....
x.bit7= y.bit? (MSB)
or if your binary number is in the pins
x.bit0 =INx
.....
ACJacques
Flaming Headphones wrote:
>
> Hello,
> Hi, I have a BS2 and I'm wondering if there is a command or something that
> will convert an 8-bit binary number into decimal form? I'm familiar with
> the calculations for manually figuring out the equivalent form, but I'm
> sure there has to be a better way of converting without coding in all the
> lines of code that would take. I want to use this decimal number within the
> program to compare two light values from my a/d convertor / phototransistor
> setup, so the debug modifier doesn't work for me in this case. Is it
> possible to use the dec modifier for debug in another way to just convert
> my binary number into decimal?
>
> Thanks,
> Mike, aka Flaming Headphones
>
>
> ICQ: 17940917
> E-mail: headphones99@i...