best way to convert binary to bcd
ohVaNiLLaGoRiLLa
Posts: 33
What is the best way to convert binary to bcd with the bs2? I am receiving an 8 bit number and want to put out the bcd equivalent
There is some way to do it with shifting to the left but im not quite sure how that works..
the only other way i can think of is with a ton of if then statements like so
I do not feel like typing that out for 0 - 255 so if there's an easier way please let me know!
i just need to do 0-255 positive numbers
There is some way to do it with shifting to the left but im not quite sure how that works..
the only other way i can think of is with a ton of if then statements like so
IF NumIn = 00000000 THEN a = 0000 AND b = 0000 AND c = 0000 '0 IF NumIn = 00000001 THEN a = 0000 AND b = 0000 AND c = 0001 '1 IF NumIn = 00000010 THEN a = 0000 AND b = 0000 AND c = 0010 '2
I do not feel like typing that out for 0 - 255 so if there's an easier way please let me know!
i just need to do 0-255 positive numbers
Comments
how would i get it to dig a variable and then use that variable with outh to output it on the desired pins?