Skip to content

Instantly share code, notes, and snippets.

View mickvangelderen's full-sized avatar

Mick van Gelderen mickvangelderen

  • The Netherlands
  • 03:50 (UTC +02:00)
View GitHub Profile
@rust-play
rust-play / playground.rs
Created November 2, 2019 12:42
Code shared from the Rust Playground
fn smart_8_to_5(n: u8) -> u8 {
(((n as u32) * 31 + 30) / 255) as u8
}
fn dumb_8_to_5(n: u8) -> u8 {
(((n as u32) * 31) / 255) as u8
}
fn just_5_to_8(n: u8) -> u8 {
(((n as u32) * 255) / 31) as u8