Thank you guys. With the help of your suggestion I get a result but I altered something in this program below.
uint16_t loWord;
uint16_t hiWord;
typedef union {
float v;
int32_t longValue;
byte b[sizeof(float)], a[sizeof(int)];
}
cracked_float_t;
cracked_float_t floatValue;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
floatValue.v = 263.3;
Serial.print("The float value is =");
Serial.println(floatValue.v);
Serial.print("The byte value of given float is =");
for (int i = 0; i < 4; i++) {
Serial.print(floatValue.b*, HEX);*
- Serial.println(" ");*
- }*
- loWord = word(floatValue.b[1], floatValue.b[0]);*
- hiWord = word(floatValue.b[3], floatValue.b[2]);*
- Serial.print("The 16 bit low byte is =");*
- Serial.println(loWord, HEX);*
- Serial.print("The 16 bit high byte is =");*
- Serial.println(hiWord, HEX);*
}
void loop() { - // put your main code here, to run repeatedly:*
}
OUTPUT IS
The float value is =263.30
The byte value of given float is =66
A6
83
43
The 16 bit low byte is =A666
The 16 bit high byte is =4383
I get a result but is the above program is correct or not. I have a small doubt is, How to convert this two 16 bit unsigned integer value into float value. Can any of you providing solution for this conversion.