young
Joined: 24 Jun 2004 Posts: 285
|
float to byte and byte to float |
Posted: Fri Jul 09, 2004 12:09 pm |
|
|
I have float data
float Total;
and I used following method to change them into BYTE, here datanum is the address
Code: |
write_ext_eeprom(datanum, shift_right(&Total,24,0) & 0xFF);
datanum=datanum+1;
write_ext_eeprom(datanum, shift_right(&Total,16,0) & 0xFF);
datanum=datanum+1;
write_ext_eeprom(datanum, shift_right(&Total,8,0) & 0xFF);
datanum=datanum+1;
write_ext_eeprom(datanum, shift_right(&Total,0,0) & 0xFF);
datanum=datanum+1;
|
to save them into a external memory
AM I right
Right now I need to read them from external memory to chip ram and transfer from BYTE to float
here
BYTE temp;
I need do something like these,put t\four byte reading into a float memory and display them, the following code is wrong, what is the correct one?
Code: |
temp=read_ext_eeprom(datanum);
datanum=datanum+1;
Total=shift_left(temp,24,0);
temp=read_ext_eeprom(datanum);
datanum=datanum+1;
Total=Total |(temp<<16);
read_ext_eeprom(datanum, temp);
datanum=datanum+1;
Total=Total |(temp<<8);
temp=read_ext_eeprom(datanum);
datanum=datanum+1;
Total=Total |temp;
|
however, from byte to float error message[/quote] |
|