Skip to content

Instantly share code, notes, and snippets.

@warmwaffles
Created November 8, 2015 03:58
Show Gist options
  • Save warmwaffles/3f145c338563efb09e0c to your computer and use it in GitHub Desktop.
Save warmwaffles/3f145c338563efb09e0c to your computer and use it in GitHub Desktop.
#include <stdint.h>
#include <string.h>
uint32_t float_to_raw_bits(float x)
{
uint32_t y;
memcpy(&y, &x, 4);
return y;
}
uint64_t double_to_raw_bits(double x)
{
uint64_t y;
memcpy(&y, &x, 8);
return y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment