I have scales application. I want to display i.e. 123.456g I have uint8 that represents 123 (scales range is 0 - 150g) I also have uint16 that represents 456 (scales range .0 - .999g)
My code:
val strValue = characteristic.getIntValue(FORMAT_UINT16,0).toFloat() + ((characteristic.getIntValue(FORMAT_UINT16,1) or characteristic.getIntValue(FORMAT_UINT16,2).shl(8)) / 1000f)
Produces 51323.457 instead of 123.456 What is wrong?
You're adding floats, not generating a string.
Convert your digits to String, then concatenate them.