Subversion Repositories Kolibri OS

Rev

Rev 4872 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2. FUNCTION
  3. <<fma>>, <<fmaf>>--floating multiply add
  4. INDEX
  5.         fma
  6. INDEX
  7.         fmaf
  8.  
  9. ANSI_SYNOPSIS
  10.         #include <math.h>
  11.         double fma(double <[x]>, double <[y]>, double <[z]>);
  12.         float fmaf(float <[x]>, float <[y]>, float <[z]>);
  13.  
  14. DESCRIPTION
  15. The <<fma>> functions compute (<[x]> * <[y]>) + <[z]>, rounded as one ternary
  16. operation:  they compute the value (as if) to infinite precision and round once
  17. to the result format, according to the rounding mode characterized by the value
  18. of FLT_ROUNDS.  That is, they are supposed to do this:  see below.
  19.  
  20. RETURNS
  21. The <<fma>> functions return (<[x]> * <[y]>) + <[z]>, rounded as one ternary
  22. operation.
  23.  
  24. BUGS
  25. This implementation does not provide the function that it should, purely
  26. returning "(<[x]> * <[y]>) + <[z]>;" with no attempt at all to provide the
  27. simulated infinite precision intermediates which are required.  DO NOT USE THEM.
  28.  
  29. If double has enough more precision than float, then <<fmaf>> should provide
  30. the expected numeric results, as it does use double for the calculation.  But
  31. since this is not the case for all platforms, this manual cannot determine
  32. if it is so for your case.
  33.  
  34. PORTABILITY
  35. ANSI C, POSIX.
  36.  
  37. */
  38.  
  39. #include "fdlibm.h"
  40.  
  41. #ifndef _DOUBLE_IS_32BITS
  42.  
  43. #ifdef __STDC__
  44.         double fma(double x, double y, double z)
  45. #else
  46.         double fma(x,y)
  47.         double x;
  48.         double y;
  49.         double z;
  50. #endif
  51. {
  52.   /* Implementation defined. */
  53.   return (x * y) + z;
  54. }
  55.  
  56. #endif /* _DOUBLE_IS_32BITS */
  57.