For anyone wondering: double -&gt; uintx_t is indeed undefined in C and C++ for values outside of (0, UINTx_MAX), which is kind of a gotcha since, double -&gt; long -&gt; uint8_t is fine (assuming all integer parts of double fit in a long).