From 13142c1477b60121c33840b8827ed17545efa784 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Mon, 30 Jan 2017 17:11:13 +1100 Subject: [PATCH] Add macro for round up/down integer division --- maths.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/maths.ino b/maths.ino index fe5c726..4c14253 100644 --- a/maths.ino +++ b/maths.ino @@ -1,5 +1,7 @@ #include "maths.h" +#define DIV_ROUND_CLOSEST(n, d) ((((n) < 0) ^ ((d) < 0)) ? (((n) - (d)/2)/(d)) : (((n) + (d)/2)/(d))) + //Replace the standard arduino map() function to use the div function instead int fastMap(unsigned long x, int in_min, int in_max, int out_min, int out_max) {