floatconv - Floating point to byte representation converter By David Lions, yizgarnoff@optushome.com.au, feedback welcome. Originally posted to: www.piclist.com, version 1.0, 19 December 2000 Description: This is a utility to convert a floating point number into it's byte pattern representation. For example, what do -6.7654 or 3425.45423E27 look like in byte form? Type the number into the Float field, press Convert To Byte. The byte representation is shown in the fields Byte1, Byte2, Byte3 and Byte4. Byte1 is the most significant byte... It can convert four different formats. Hitech 24 Bit (truncated IEEE 754 32Bit), IEEE 754 32Bit, Microchip 24Bit and Microchip 32Bit. The Microchip formats referred to here are presented in Microchip Application Note AN575. It can also convert back from byte representation to floating point. You don't need to know what the mantissa and exponent do to use this utility. You can ignore those fields. Purpose: The purpose was to manually alter calibration values in a PIC-based device. We had to alter a floating point number byte-by-byte so it was still readable by the compiled code. It is not trivial to convert a floating point value on paper into byte representation. Contents: This archive contains the entire project. It was a Visual C++ Dialog Box program created with AppWizard. You probably dont have Visual C, so the final executeable is in the 'Release' directory. Issues (work for version 1.1): * There is rounding error. Only noticed this in 32bit form. I believe if the last bit of the mantissa may get rounded down. Won't be a problem for most so I wont fix it. This will give an error of +/- e * (2**exp) where exp is the unbiased exponent and e is the error, e=1/(2**23) for 32Bit formats and e=1/(2**15) for 24Bit formats. You basically lose 1 bit of mantissa, and this round is _biased_, i.e. your number is always rounded closer to zero. I don't have any more time to look at this. * Converting back and forward produces different results. This happens in 32Bit formats mostly. I think this is also related to the rounding error. * Change to JavaScript would be better - editor (notepad.exe), compiler (web browser) and executeable (web page) are extremely portable. Legal: I do not guarantee that this software will work the way it was intended. I do not take responsibility for anything that happens to anyone or anything, at any time, as a result of using this or any software, in any way. If you change this software and distribute it publicly, you must identify yourself as the new contact point, and remove all occurences of my email address (yizgarnoff@optushome.com.au). Enjoy. Time spent writing utility: 10 hours Time spent writing ReadMe.txt: 20 hours