diff --git a/README.md b/README.md index 4eb5172..3b454ed 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ Don't. The makefile only includes a test target, because I want to test my code. ```c silly silly_zeros(); // creates a fixed point value of zero - silly make_silly(short, int, int); // make a silly number from the triple (negative?, before decimal, after) + double silly_to_double(silly); // convert a silly number into a double silly silly_add(silly, silly); // addition diff --git a/silly.c b/silly.c index f56b43b..ad67ace 100644 --- a/silly.c +++ b/silly.c @@ -88,3 +88,11 @@ char* silly_to_string(silly s) { double silly_to_double(silly s) { return ((double)s.before + ((double)s.after)/(double)0xffffffff) * (s.sign ? -1 : 1); } + +silly make_silly(short sign, int before, int after) { + silly s; + s.sign = sign; + s.before = before; + s.after = after; + return s; +} diff --git a/silly.h b/silly.h index cc203a5..1d75e95 100644 --- a/silly.h +++ b/silly.h @@ -9,6 +9,7 @@ typedef struct { } silly; silly silly_zeros(); +silly make_silly(short, int, int); silly silly_add(silly, silly); silly silly_sub(silly, silly);