This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: Single precision


Thanks for the help.

Chris

Peter Barada said:
>
>>A better solution is probably to #define double float immediately after
>>including any header files.
>
> If so, then cast all the floating point constants so the compiler will
> use them as single precision constants instead of their default of
> double precision which will then cause the float to get promoted to a
> double and *then* operate on the constant.  Unless you case the
> constants, the code will end up slower.  As an example:
>
> #define double float
> double float_abs(double a, double b)
> {
>  if (a >= (double)0.0)
>    return a;
>  else
>    return -a;
> }
>
> If the zero wasn't case to double(which via the #define is really a
> float, then the comparison will be done in dboule precision *after* 'a'
> is converted from single precision to double.
>
> Hope this helps...
>
> --
> Peter Barada
> Peter.Barada@motorola.com Wizard
>  781-852-2768 (direct) WaveMark Solutions(wholly owned by Motorola)
> 781-270-0193 (fax)




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