From dff562c47c47fcac90c116782c92b692f2bb9bf9 Mon Sep 17 00:00:00 2001 From: Léo Gourdin Date: Thu, 22 Apr 2021 11:25:02 +0200 Subject: moving my tests --- test/gourdinl/c/floor.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/gourdinl/c/floor.c (limited to 'test/gourdinl/c/floor.c') diff --git a/test/gourdinl/c/floor.c b/test/gourdinl/c/floor.c new file mode 100644 index 00000000..33a57af3 --- /dev/null +++ b/test/gourdinl/c/floor.c @@ -0,0 +1,29 @@ +int main(int n) +{ + int x = 1, i; + + /* for positive values */ + if (n > 0) + { + for (; x <= n >> 1;) + { + x = x << 1; + } + n = x; + } + /* for negative values */ + else + { + n = ~n; + n = n + 1; + for (; x <= n >> 1;) + { + x = x << 1; + } + x = x << 1; + x = ~x; + x = x + 1; + n = x; + } + return n; +} -- cgit