This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Printing single-precision floating point values


On 06/10/2015 12:54 PM, Uladzislau Paulovich wrote:
> How to use printf() function to print single-precision floating point
> values on the architecture that doesn't support double-precision
> floating point values? I've just found out that vfprintf() function uses
> "isinf(double)" function even for printing floats and therefore it
> crashes on my target architecture (armv7m-hardfloat-eabi).

'float' promotes to 'double' when passed through varargs like vfprintf.
 What's more, C99 requires that 'double' have at least DBL_DIG of 10,
but IEEE single-precision only allows for FLT_DIG of 6, so I don't see
how you can comply with C99 while using only single precision.  That
said, I see nothing in C99 that would forbid 'double' from being an
identical type to 'float' (both being IEEE double precision, perhaps),
if you define <math.h> FLT_EVAL_METHOD to 1, and can convince the
compiler to go along with that type setup.

But newlib is known for trying to support odd platforms, so if you can
come up with patches to make things work in spite of not complying with
C99 because you only have single precision, and the patches aren't too
difficult to maintain, we can probably take them.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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