--- layout: post title: "A0 -> O1 -> A1 ??" date: 2017-03-20 02:43:00 +0000 --- 其實呢個encoding 究竟係邊個發明,點解可以咁on9 點解A 個domain 係ℕ 但係O 個domain 係ℤ₊ 點解A0 之後唔係O0 而係O1 A0 跳O0 嘅話一個ripple carry adder 就得 每次state change 就加1,LSB 拆出黎分A/O,淨低做value init() { status = 0; } onStateChange() { status++; } decode() { state = status & 1; value = status >> 1; } A0 跳O1 嘅話 一係就要skip 一個status (init 做1 或者0 skip 去2) 一係就改decode logic 前者少咗一個representable value,後者用多咗logic gate