On 2007-08-28 22:01Z, Vincent Torri wrote:
> As mentioned in the wiki, printf-like functions can not handle the %a
> modifier character.
> I need it in a library to convert from double to string and conversely
> using the format specified by %a.
What goal do you seek to accomplish by converting between doubles
and their "%a" representations? (Perhaps there's another way.)
> I've already written a function that does the conversion of a string to a
> double. It's not very complicated.
> Now, I would need to convert a double to a string, using the format
> that would be created by snprintf ("%a"). I'm a bit lost, as, as mentioned
> in the documentation of printf :
> "If the precision is missing, it is taken as enough to represent the
> floating-point number exactly, and no rounding occurs." 
> I don't know how to achieve that.
An IEEE 754 double is stored as binary and has only a finite number
of bits, so showing them all would suffice; drop trailing zeros if
you like. I'm curious why you're asking this particular question:
isn't this the easiest case?
You'd have to consider NaNs and other special values, of course.
> Does someone has ideas, or hints, or links to do such thing ?
The citation you gave is a BSD manpage, so the BSD sources would
give a reference implementation. Others would also be available
on the web.