This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Parsing a Floating-Point


On Fri, Oct 05, 2001 at 07:53:36PM +0100, Nick Clifton wrote:
> Hi Tracy,
> 
> > I am trying to parse a floating-point number required by a directive
> > I am trying to add.  I want to try to utilize the md_atof function,
> > but am unsure of how to convert the resulting value to a
> > floating-point value to do math on.  Any help would be appreciated.
> 
> You are probably just better off using sscanf to convert the text in
> the input stream into a floating point value.
> 
> The problem with using md_atof() is that it converts the number into a
> byte array representation of the floating point value, but this byte
> array will be ordered according to the target's endianness, not the
> hosts.  Thus if you extract the bytes from the array you will have to
> worry about endian conversions as well.  Plus if you have, say a
> 64bit host, its doubles might well be 128 bits long, whereas the
> convert byte array will probably only be 64 bit longs (if the target
> is a 32 bit target).

Well the more generic problem is your target and host might use different
floating point formats (though IEEE format is pretty dominant, you don't want
to code in a fashion that is less than portable).

-- 
Michael Meissner, Red Hat, Inc.  (GCC group)
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]