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


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).

Cheers
        Nick


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