You're viewing a comment by dj and its responses.

December 16, 2013, 17:16

I just read your bash articles and thought, these could easily be converted into bash using (( )) syntax around the bitwise tests. Input data as such: 2#0010,1011 or 43.
As far as printf:
if input is decimal and you want to see binary use:
pos: "$(echo "obase=2; ibase=10; x" | bc)"
neg: "$(echo "obase=2; ibase=10; $((2**wordSize - x))" | bc)"
if input is binary and you want to see decimal use:
pos: "$(echo "obase=10; ibase=2; $x" | bc)"
neg: $(( ~0xff | 2#$x ))
I wouldn't call your article hacks, these are standard practices, especially for assembler programming.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "quake3_143": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.