I have scales application. I want to display ie 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.