aboutsummaryrefslogtreecommitdiff
path: root/strings.h
blob: 7721f6374fcfdc2f9d3386d6d8c8b56a56f5fc47 (about) (plain)
1
2
3
4
5
6
7
8
9
#include <stdint.h>

void uint32_to_bits(uint32_t number, char *buf)
{
  for (int i = 0; i < 32; i++)
    buf[i] = ((number >> (32 - i - 1)) & 1) ? '1' : '0';

  buf[32] = '\0';
}