Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - how to convert DEC to bits

(you are viewing a thread; or go back to list of threads)

how to convert DEC to bits (by marzook)
Hello

i want to convert the number (5)DEC
to to BITS=(101)BIN

can u help?
Sat Jan 16 2010, 14:09:05
(no subject) (by Jonathan Westhues)
I'm assuming that you have an integer variable, and you want to write it out on multiple digital outputs, in binary format. See the attachment for example; this pulls the top 4 bits out of a 10-bit number, so the places are valued at 512, 256, 128, and 64.

In your case, the places would be valued at 4, 2, and 1. Everything else stays the same.

A similar method can be used for other codes (like BCD, with place values 1 2 4 10 20 ...).
Sat Jan 16 2010, 16:05:59, download attachment binary-out.ld
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):