From 4437c46825b34ced12a5e6babd4d681067c79db1 Mon Sep 17 00:00:00 2001 From: Sander Boele Date: Sat, 11 Apr 2015 11:26:44 +0200 Subject: [PATCH] fixed floating point problem in bcd conversions --- lua_modules/ds3231/ds3231.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua_modules/ds3231/ds3231.lua b/lua_modules/ds3231/ds3231.lua index 48b0fd86..d13b89e8 100644 --- a/lua_modules/ds3231/ds3231.lua +++ b/lua_modules/ds3231/ds3231.lua @@ -16,11 +16,11 @@ local id = 0 local dev_addr = 0x68 local function decToBcd(val) - return((val/10*16) + (val%10)) + return((((val/10) - ((val/10)%1)) *16) + (val%10)) end local function bcdToDec(val) - return((val/16*10) + (val%16)) + return((((val/16) - ((val/16)%1)) *10) + (val%16)) end -- initialize i2c