Decbinary See merge request fdai7848/Linkes-Twix!13
@ -0,0 +1,17 @@
#include <stdio.h>
#include "decbinary.h"
int decimal_to_binary(int dezimalzahl) {
int binärzahl[32];
int i = 0;
while (dezimalzahl > 0) {
binärzahl[i++] = dezimalzahl % 2;
dezimalzahl /= 2;
}
return i;
@ -0,0 +1,8 @@
#ifndef LINKES_TWIX_DECBINARY_H
#define LINKES_TWIX_DECBINARY_H
int decimal_to_binary(int dezimalzahl);
#endif //LINKES_TWIX_DECBINARY_H
@ -0,0 +1,18 @@
#ifdef TEST
#include "unity.h"
void setUp(void)
{
void test_decimal_1(void)
int result, expected = 10;
result = decimal_to_binary(2);
TEST_ASSERT_EQUAL_INT(expected, result);
#endif //TEST