nandi/rustnimpublic Fork 0
main
Commits
Clone
git clone https://git.rickub.com/nandi/rustnim.git
git clone ssh://git@rickub.com/nandi/rustnim.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

005-base16ct-decode-core.rs · 18 lines · 515 BRust Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
// The exact expression from base16ct 1.0.0 that the other transpiler's
// float64 universal AST cannot represent. Milestone 1 in miniature.
fn decode_nibble(src: u8) -> i16 {
    let byte = src as i16;
    let mut ret: i16 = -1;
    ret += (((0x2fi16 - byte) & (byte - 0x3a)) >> 8) & (byte - 47);
    ret += (((0x60i16 - byte) & (byte - 0x67)) >> 8) & (byte - 86);
    ret
}

fn main() {
    let mut i: u8 = 0;
    while i < 128 {
        print!("{} ", decode_nibble(i));
        i += 1;
    }
    println!("");
}