fork(1) download
  1. #include <stdint.h>
  2. typedef int8_t i8;
  3. typedef int16_t i16;
  4. typedef int32_t i32;
  5. typedef int64_t i64;
  6.  
  7. typedef uint8_t u8;
  8. typedef uint16_t u16;
  9. typedef uint32_t u32;
  10. typedef uint64_t u64;
  11. typedef float f32;
  12. typedef double f64;
  13.  
  14. typedef struct {u32 s1, s2, s3;} taus88_t;
  15.  
  16. taus88_t make_taus88(u32 seed);
  17. u32 taus88u32(taus88_t *t);
  18. f32 taus88f32(taus88_t *t);
  19.  
  20. taus88_t make_taus88(u32 seed)
  21. {
  22. taus88_t t;
  23. t.s1 = 1243598713U ^ seed; if (t.s1 < 2) t.s1 = 1243598713U;
  24. t.s2 = 3093459404U ^ seed; if (t.s2 < 8) t.s2 = 3093459404U;
  25. t.s3 = 1821928721U ^ seed; if (t.s3 < 16) t.s3 = 1821928721U;
  26. return t;
  27. }
  28.  
  29. u32 taus88u32(taus88_t *t)
  30. {
  31. t->s1 = ((t->s1 & -2) << 12) ^ (((t->s1 << 13) ^ t->s1) >> 19);
  32. t->s2 = ((t->s2 & -8) << 4) ^ (((t->s2 << 2) ^ t->s2) >> 25);
  33. t->s3 = ((t->s3 & -16) << 17) ^ (((t->s3 << 3) ^ t->s3) >> 11);
  34. return t->s1 ^ t->s2 ^ t->s3;
  35. }
  36.  
  37. f32 taus88f32(taus88_t *t)
  38. {
  39. union {u32 i ; f32 f ;} u;
  40. u.i = 0x3F800000 | (taus88u32(t) >> 9);
  41. return u.f - 1.0;
  42. }
  43.  
  44. int main()
  45. {
  46.  
  47. taus88_t* TAUS88 ;
  48.  
  49. *TAUS88 = make_taus88(6346456);
  50. u32 numberu32 = taus88u32(TAUS88);
  51. f32 numberf32 = taus88f32(TAUS88);
  52.  
  53. return 0;
  54. }
Runtime error #stdin #stdout 0s 2892KB
stdin
Standard input is empty
stdout
Standard output is empty