top | item 37808608

(no title)

khangaroo | 2 years ago

I posted this on the thread in /r/programming a while ago, but I might as well post this here too. It's possible to implement the adder in "only" 11 subtractions:

    fn adder(a: Bit, b: Bit, c: Bit) -> (Bit, Bit) {
        let r0 = c - b;
        let r1 = c - r0;
        let r2 = ZERO - r0;
        let r3 = b - r1;
        let r4 = r2 - r3;
        let r5 = a - r4;
        let r6 = r4 - a;
        let r7 = ZERO - r5;
        let r8 = r7 - r1;
        let r9 = r7 - r6;
        let r10 = ZERO - r8;
        (r9, r10)
    }

discuss

order

No comments yet.