Hacker News new | ask | show | jobs
by vanderZwan 2127 days ago
Thanks for the tips!

(also, as you might have noticed, HN doesn't support MD proper. To get code blocks you have to indent it with four spaces)

    const eps: f64 = 2.3283064365386963e-10;
    const m: u64 = 6364136223846793005;
    const inc: u64 = 1442695040888963407;
    
    let state: u64 = 1;
    
    export function random(): f64 {
      let oldstate = state * 6364136223846793005 + 1442695040888963407;
      state = oldstate;
      const xorshifted = u32(((oldstate >>> 18) ^ oldstate) >> 27);
      const out_int = rotr(xorshifted, u32(oldstate >> 59));
      return eps * out_int;
    }
2 comments

(Technical note: two spaces of indentation is sufficient. Note also how the common leading spaces are not removed.)
Ah, thank you!
> To get code blocks you have to indent it with four spaces

I'll keep that in mind in next time. Thanks for the tip!