From: Sai on 8 Jun 2010 06:32 Im reading data from serial port as int16 class but i could not convert it into float using any of the functions float,cast,typecast. They say that int to float is not supported. somebody plz tell me how can i do typecasting from int16/uint16 to float/double??? Thnx
From: Jan Simon on 8 Jun 2010 07:48 Dear Sai! > Im reading data from serial port as int16 class but i could not convert it into float using any of the functions float,cast,typecast. They say that int to float is not supported. somebody plz tell me how can i do typecasting from int16/uint16 to float/double??? Do you know that "float" is called "single" in Matlab? This should solve the problems. Jan
From: Walter Roberson on 8 Jun 2010 08:33 Sai wrote: > Im reading data from serial port as int16 class but i could not convert > it into float using any of the functions float,cast,typecast. They say > that int to float is not supported. somebody plz tell me how can i do > typecasting from int16/uint16 to float/double??? If you need to typecast to float or double and you do not need to rearrange the bytes, then read the port as float or double. If you _do_ need to rearrange the bytes, then chances are good that you have to swap the upper and lower byte within the 16 bits, so you should read as uint8 and rearrange the bytes and typecast that.
|
Pages: 1 Prev: sets of subsets generated by 'permpos.m' --- looping? Next: imwrite |