-->
Page 1 of 1

Decimal-to-Binary conversion

PostPosted: Fri Feb 24, 2017 3:10 am
by trackerj
Let's move formward with the colection of the handy subroutines and implement a decimal-to-binary conversion one:

Code: Select all [decbin]
  i = 1
  r = 0
  binval = 0
  nr = decval
 Do
   r = nr % 2
   nr = int(nr/2)
   binval = binval + r*i
   i = i*10
 Loop while nr > 0
wait


Original article with full program code :
ESPBasic decimal-to-binary conversion code and test program

Looking forward to hear about your own ideas/solutions.

Happy breadboarding,
TJ.