How to convert power consumption value.

Status
Not open for further replies.

alphadog

Banned
My chip brings me power consumption value.
It has a calibrated value Y (3 hexa bytes), that represents X WAT, and each time it sends me a value Z (3 hexa bytes)
Meaning, when i recieve Y from the Chip, i know that the power consumption is X WAT.
And when i receive Z from the chip, i know that the power consumption is
Z / Y * X.

The problem with Z / Y * X is that when i read the result of it in hexa, i'm getting an integer, and therefore losing accuracy.
All numbers i read are in hexa, meaning i cant receive a number in decimal (double type).

How can I be more accurate?

Thank you!
 
Last edited:
Multiply the variables x100 so integer math is all you need. Then just put the decimal back in the right place. Or load a floating point library.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…