From 9c8ece1538d31dba9a416c9f29f88e18510f4c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Ma=C5=BEeikis?= Date: Sat, 18 May 2019 16:32:20 +0300 Subject: Whole-project: partial implementation of protocol. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit is part of ticket #31. Branch is not in a compiling state. Work is being done on utility functions and protocol implementation. To be completed later. Signed-off-by: Ramūnas Mažeikis --- src/common/utils.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/common/utils.c (limited to 'src/common/utils.c') diff --git a/src/common/utils.c b/src/common/utils.c new file mode 100644 index 0000000..7bcf767 --- /dev/null +++ b/src/common/utils.c @@ -0,0 +1,22 @@ +#include "utils.h" + +fpi1_t add(fpi1_t a, fpi1_t b) +{ + return a + b; +} + +fpi1_t sub(fpi1_t a, fpi1_t b) +{ + return a - b; +} + +fpi1_t mul(fpi1_t a, fpi1_t b) +{ + return (fpi1_t)(((long)a * (long)b) / 100); +} + +fpi1_t div(fpi1_t a, fpi1_t b) +{ + return (fpi1_t)(((long)a * 10) / ((long)b * 10)); +} + -- cgit v1.2.3