Boost logo

Boost :

From: pbristow_at_[hidden]
Date: 2019-10-15 10:12:39

> -----Original Message-----
> From: Boost <boost-bounces_at_[hidden]> On Behalf Of Phil Endecott via
> Sent: 14 October 2019 20:15
> To: boost_at_[hidden]
> Cc: Phil Endecott <spam_from_boost_dev_at_[hidden]>
> Subject: [boost] [Math] float16 on ARM
> Hi,
> There seems to be support for 16-bit floats on iOS, when using Apple's XCode
> clang. This seems to be a storage-only format with the only instruction set
> being conversions to and from 32- and 64-bit floats. Quick test:
> #if __ARM_FP & 2
> #warning "Have 16-bit FP"
> #endif
> void test()
> {
> __fp16 a = 1.234;
> static_assert(sizeof(a)==2);
> __fp16 b = 2.345;
> auto sum = a+b;
> static_assert(sizeof(sum)==4);
> }
> There doesn't seem to be a std::numeric_limits specialisation.
> I suspect that other platforms have something similar. It would be good to
have a
> boost::float16_t typedef and a portable feature-test macro (and maybe a
> fallback). As far as I can see, boost/math/cstdfloat/cstdfloat_types.hpp
checks the
> sizes of float, double and long double, and checks for 128-bit floats provided
> the compiler. Can this be extended to check for __fp16 ?
> (P.S. it seems that gcc also has support, see
> )

I:\boost\libs\math\include\boost\math\cstdfloat\cstdfloat_types.hpp has some
mention for 16-bit floating-point double.

Is this the only 16-bit floating-point format in use?

The storage-only nature of the type is another complication.

But in principle, yes, I support this (but am uncertain how to implement it in


Paul A. Bristow
Prizet Farmhouse
Kendal, Cumbria

Boost list run by bdawes at, gregod at, cpdaniel at, john at