added make_silly
This commit is contained in:
@@ -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
|
||||
|
8
silly.c
8
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user