Skip to content

Instantly share code, notes, and snippets.

View shterrett's full-sized avatar

Stuart Terrett shterrett

View GitHub Profile
@shterrett
shterrett / playground.rs
Last active January 17, 2017 19:02 — forked from anonymous/playground.rs
Shared via Rust Playground
// http://stackoverflow.com/a/39639200
use std::mem;
use std::hash::{Hash, Hasher};
use std::collections::HashSet;
use std::fmt;
fn integer_decode(val: f64) -> (u64, i16, i8) {
let bits: u64 = unsafe { mem::transmute(val) };
let sign: i8 = if bits >> 63 == 0 { 1 } else { -1 };