Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial checkin (floor and ceil with n decimals)

  • Loading branch information...
commit 218447fa5a90cebc1798dd9a892acfb1b951b1cd 1 parent 96c245d
@ettore authored
Showing with 49 additions and 0 deletions.
  1. +24 −0 clcg_math.h
  2. +25 −0 clcg_math.m
View
24 clcg_math.h
@@ -0,0 +1,24 @@
+//
+// clcg_math.h
+// Goodreads
+//
+// Created by Ettore Pasquini on 2/2/12.
+// Copyright (c) 2012 Goodreads. All rights reserved.
+//
+
+#ifndef CLCG_MATH_H_
+#define CLCG_MATH_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ double clcg_floor(double n, unsigned decimals);
+
+ double clcg_ceil(double n, unsigned decimals);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
View
25 clcg_math.m
@@ -0,0 +1,25 @@
+//
+// clcg_math.m
+// Goodreads
+//
+// Created by Ettore Pasquini on 2/2/12.
+// Copyright (c) 2012 Goodreads. All rights reserved.
+//
+
+#include <math.h>
+
+#import "clcg_math.h"
+
+
+double clcg_floor(double n, unsigned decimals)
+{
+ double mul = pow(10, decimals);
+ return floor(n * mul) / mul;
+}
+
+
+double clcg_ceil(double n, unsigned decimals)
+{
+ double mul = pow(10, decimals);
+ return ceil(n * mul) / mul;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.