aboutsummaryrefslogtreecommitdiff
path: root/strings.h
blob: 2ceade839a2477f50ac9b6e23050169271357b30 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef STRINGS_H
#define STRINGS_H

#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';
}

#endif // STRINGS_H