summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-12-02 12:52:37 +0100
committerMichal Idziorek <m.i@gmx.at>2014-12-02 12:52:37 +0100
commit5435237fca6b7ab618bfc955e2973d7b325ff9dc (patch)
tree1a2929199f86734a629f5bbe5281c668162cc1fa
parent4d376279836b0e21d04c9d94b0ead0a29e57db2e (diff)
added and tested libm (newlib)
-rw-r--r--userspace/Makefile2
-rw-r--r--userspace/add.c10
2 files changed, 8 insertions, 4 deletions
diff --git a/userspace/Makefile b/userspace/Makefile
index 3e4a00f..8516bc1 100644
--- a/userspace/Makefile
+++ b/userspace/Makefile
@@ -7,6 +7,7 @@ CFLAGS+=-w
CFLAGS+=-std=gnu11
CFLAGS+=-O3
+
PROGS=foolshell ls simple brainfuck add checker clear task1 task2 init
ext2.img: $(PROGS)
@@ -32,6 +33,7 @@ brainfuck: brainfuck.o
foolshell: foolshell.o
simple: simple.o
add: add.o
+ $(CC) -o $@ $< -lm
checker: checker.o
task1: task1.o
task2: task2.o
diff --git a/userspace/add.c b/userspace/add.c
index 3a624be..04f7f17 100644
--- a/userspace/add.c
+++ b/userspace/add.c
@@ -2,12 +2,13 @@
#include <string.h>
#include <stdint.h>
#include "../fs/fs.h"
+#include <math.h>
int main(int argc, char **argv)
{
- int sum=0;
- int i=0;
+ float sum=0;
+ float i=0;
char *buf=malloc(256);
puts("\n*** fools calculator ***");
@@ -26,8 +27,9 @@ int main(int argc, char **argv)
if(i!=0)
{
puts("--------");
- printf("sum = %i \n",sum);
- printf("avg = %i \n\n",sum/i);
+ printf("sum = %f \n",sum);
+ printf("avg = %f \n",sum/i);
+ printf("sin(avg) = %f \n\n",sin(sum/i));
}
return 0;