initial
This commit is contained in:
7
Makefile
Normal file
7
Makefile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
LIBFILES=sileee.c
|
||||||
|
TESTFILES=$(wildcard tests/*.c)
|
||||||
|
|
||||||
|
test:
|
||||||
|
gcc $(LIBFILES) $(TESTFILES) -o test_silly
|
||||||
|
./test_silly
|
||||||
|
rm test_silly
|
8
README.md
Normal file
8
README.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# silleee
|
||||||
|
|
||||||
|
A reboot of [silly](https://github.com/hellerve/silly) that tries
|
||||||
|
to implement IEEE-754 floating point numbers. The audacity!
|
||||||
|
|
||||||
|
The name is a mashup of `silly` and `IEEE-754`.
|
||||||
|
|
||||||
|
WIP.
|
7
silleee.c
Normal file
7
silleee.c
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
silleee silleee_sub(silleee x, silleee y) {
|
||||||
|
y ^= 0x80000000;
|
||||||
|
return silleee_add(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
silleee silleee_add(silleeee x, silleeee y) {
|
||||||
|
}
|
10
silleee.h
Normal file
10
silleee.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#define asreal(x) (*((float *) &x))
|
||||||
|
#define exponent(x) (((x >> 23) & 0xff) - 127)
|
||||||
|
#define sign_bit 1 << 31
|
||||||
|
#define sign(x) ((x & sign_bit) >> 31)
|
||||||
|
#define mantissa(x) ((x & sign_bit) ? ((x & 0x7fffff) | 0x800000) : 0)
|
||||||
|
|
||||||
|
typedef long unsigned silleee;
|
||||||
|
|
||||||
|
sillee silleee_add(sillee, sillee);
|
||||||
|
sillee silleee_sub(sillee, sillee);
|
1040
tests/greatest.h
Normal file
1040
tests/greatest.h
Normal file
File diff suppressed because it is too large
Load Diff
26
tests/test.c
Normal file
26
tests/test.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#include "greatest.h"
|
||||||
|
#include "../silleee.h"
|
||||||
|
|
||||||
|
#define DELTA 0.01
|
||||||
|
|
||||||
|
#define ASSERT_DELTA(expected, actual) {\
|
||||||
|
double delta = expected-actual;\
|
||||||
|
ASSERT_IN_RANGE(0, delta, DELTA);\
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST silleee_zeros_is_zero() {
|
||||||
|
}
|
||||||
|
|
||||||
|
SUITE(tests) {
|
||||||
|
RUN_TEST(silly_zeros_is_zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
GREATEST_MAIN_DEFS();
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
GREATEST_MAIN_BEGIN();
|
||||||
|
|
||||||
|
RUN_SUITE(tests);
|
||||||
|
|
||||||
|
GREATEST_MAIN_END();
|
||||||
|
}
|
Reference in New Issue
Block a user