Here's what I do: void Get_ObEEROM_Float(BYTE addr, float * pdata) { PBYTE pd = (PBYTE)pdata; *pd++ = Get_ObEEROM_Byte(addr++); *pd++ = Get_ObEEROM_Byte(addr++); *pd++ = Get_ObEEROM_Byte(addr++); *pd = Get_ObEEROM_Byte(addr); } I have a Delphi 5 windows application that converts the floating point text into Microchip float format and then writes it over the serial port as two 16 bit HEX values to the target which saves it into EEROM. When the Delphi app is launched it reads a HEX dump of EEROM and pulls the data into floats that are then displayed in the text boxes. You just have to make sure you keep track of BYTE ordering. John Dammeyer Automation Artisans Inc. http://www.autoartisans.com Ph. 1 250 544 4950 > -----Original Message----- > From: piclist-bounces@mit.edu > [mailto:piclist-bounces@mit.edu] On Behalf Of Barry Gershenfeld > Sent: Tuesday, March 27, 2007 2:13 PM > To: Microcontroller discussion list - Public.; > Microcontroller discussion list - Public. > Subject: Re: [PIC] float to byte - byte to float in C > > > At 04:47 PM 3/8/07 -0500, William Couture wrote: > > >You can reference the individual bytes in a float by either > using a union: > > union float_bytes > > { > > float value; > > unsigned char bytes[sizeof(float)]; > > } myvar; > > > > myvar.value = 123.456; > > for (i = 0; i < sizeof(float); i++) > > { > > write_eeprom_byte(ee_base+i,myvar.bytes[i]); > > } > >Bill > > I have long wanted something that could do this, but alas, my > K&R tells me: > > " Any of these types may be assigned to u and then used in > expressions, so > long as the usage is consistent: the type retrieved must be > the type most > recently stored. It is the programmer's responsibility to > keep track of > which type is currently stored in a union; the results are > implementation-dependent if something is stored as one type > and extracted > as another. " > > I'd go as far as saying that C should have been provided with > something > that did what you're trying above. As an ex-assembly > language programmer, > I resent being told how I can access my data :-) > > Barry > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist