fixed floating point problem in bcd conversions

This commit is contained in:
Sander Boele 2015-04-11 11:26:44 +02:00
parent 263179ea14
commit 4437c46825
1 changed files with 2 additions and 2 deletions

View File

@ -16,11 +16,11 @@ local id = 0
local dev_addr = 0x68 local dev_addr = 0x68
local function decToBcd(val) local function decToBcd(val)
return((val/10*16) + (val%10)) return((((val/10) - ((val/10)%1)) *16) + (val%10))
end end
local function bcdToDec(val) local function bcdToDec(val)
return((val/16*10) + (val%16)) return((((val/16) - ((val/16)%1)) *10) + (val%16))
end end
-- initialize i2c -- initialize i2c