October 09, 2024, 03:28:47 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Decimal to binary and back

Started by Andy, March 08, 2021, 12:10:53 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

March 08, 2021, 12:10:53 AM Last Edit: March 08, 2021, 12:17:53 AM by Andy
Hi,

Well keeping busy again, something like this might have been posted before, but because I could only find half of what I wanted I thought I would do the other half (binary to decimal) and post it all together.

Here we are taking a decimal value and converting it to a binary string, I'm using what LarryMc posted for this first part.

The second part (I might have already posted something like this as well) I am converting the binary string back to a decimal value.

As the binary string will vary in length, I'm making sure it's packed to 16 digits.

I know quite a few of you use binary from time to time, so I thought I would post
this all in one place.

Thanks,
Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.