[Libclc-dev] [PATCH] Add definition for M_PI_F v2
Tom Stellard
tom at stellard.net
Tue Mar 11 09:20:27 PDT 2014
Hi Jeroen,
I used this test program to generate the hexadecimal constant for pi:
#include <math.h>
#include <stdio.h>
int main(int argc, char ** argv)
{
union {
float f;
unsigned i;
} pi;
pi.f = M_PI;
fprintf(stderr, "Pi = %f pi = 0x%x\n", pi.f, pi.i);
}
-Tom
On Tue, Mar 11, 2014 at 04:10:51PM +0000, Jeroen Ketema wrote:
>
> Hi Tom,
>
> Why do you write this hexadecimal value directly as a float, i.e., as 3.14159274101257f ?
>
> Jeroen
>
> On 11 Mar 2014, at 15:38, Tom Stellard <thomas.stellard at amd.com> wrote:
>
> > v2:
> > - Use a hexadecimal constant.
> > ---
> > generic/include/clc/float/definitions.h | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> >
> > diff --git a/generic/include/clc/float/definitions.h b/generic/include/clc/float/definitions.h
> > index e6ef1d8..a6c947f 100644
> > --- a/generic/include/clc/float/definitions.h
> > +++ b/generic/include/clc/float/definitions.h
> > @@ -9,6 +9,17 @@
> > #define FLT_MIN 0x1.0p-126f
> > #define FLT_EPSILON 0x1.0p-23f
> >
> > +_CLC_INLINE static float m_pi_f() {
> > + union {
> > + unsigned i;
> > + float f;
> > + } pi;
> > + pi.i = 0x40490fdb;
> > + return pi.f;
> > +}
> > +
> > +#define M_PI_F m_pi_f()
> > +
> > #ifdef cl_khr_fp64
> >
> > #define DBL_DIG 15
> > --
> > 1.8.1.5
> >
> >
> >
> > _______________________________________________
> > Libclc-dev mailing list
> > Libclc-dev at pcc.me.uk
> > http://www.pcc.me.uk/cgi-bin/mailman/listinfo/libclc-dev
>
>
> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at pcc.me.uk
> http://www.pcc.me.uk/cgi-bin/mailman/listinfo/libclc-dev
More information about the Libclc-dev
mailing list