You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
4.6 KiB

  1. /**
  2. @file
  3. @ingroup epd
  4. @brief The University of Colorado extended double precision package.
  5. @details Arithmetic functions with extended double precision. The floating
  6. point numbers manipulated by this package use an int to hold the exponent.
  7. The significand has the same precision as a standard double.
  8. @author In-Ho Moon
  9. @copyright@parblock
  10. Copyright (c) 1995-2015, Regents of the University of Colorado
  11. All rights reserved.
  12. Redistribution and use in source and binary forms, with or without
  13. modification, are permitted provided that the following conditions
  14. are met:
  15. Redistributions of source code must retain the above copyright
  16. notice, this list of conditions and the following disclaimer.
  17. Redistributions in binary form must reproduce the above copyright
  18. notice, this list of conditions and the following disclaimer in the
  19. documentation and/or other materials provided with the distribution.
  20. Neither the name of the University of Colorado nor the names of its
  21. contributors may be used to endorse or promote products derived from
  22. this software without specific prior written permission.
  23. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  26. FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  27. COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  28. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  29. BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  33. ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  34. POSSIBILITY OF SUCH DAMAGE.
  35. @endparblock
  36. */
  37. #ifndef EPD_H_
  38. #define EPD_H_
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. /*---------------------------------------------------------------------------*/
  43. /* Type declarations */
  44. /*---------------------------------------------------------------------------*/
  45. /**
  46. @brief The type of extended precision floating-point numbers.
  47. */
  48. typedef struct EpDoubleStruct EpDouble;
  49. /*---------------------------------------------------------------------------*/
  50. /* Function prototypes */
  51. /*---------------------------------------------------------------------------*/
  52. extern EpDouble *EpdAlloc(void);
  53. extern int EpdCmp(const void *key1, const void *key2);
  54. extern void EpdFree(EpDouble *epd);
  55. extern void EpdGetString(EpDouble const *epd, char *str);
  56. extern void EpdConvert(double value, EpDouble *epd);
  57. extern void EpdMultiply(EpDouble *epd1, double value);
  58. extern void EpdMultiply2(EpDouble *epd1, EpDouble const *epd2);
  59. extern void EpdMultiply2Decimal(EpDouble *epd1, EpDouble const *epd2);
  60. extern void EpdMultiply3(EpDouble const *epd1, EpDouble const *epd2, EpDouble *epd3);
  61. extern void EpdMultiply3Decimal(EpDouble const *epd1, EpDouble const *epd2, EpDouble *epd3);
  62. extern void EpdDivide(EpDouble *epd1, double value);
  63. extern void EpdDivide2(EpDouble *epd1, EpDouble const *epd2);
  64. extern void EpdDivide3(EpDouble const *epd1, EpDouble const *epd2, EpDouble *epd3);
  65. extern void EpdAdd(EpDouble *epd1, double value);
  66. extern void EpdAdd2(EpDouble *epd1, EpDouble const *epd2);
  67. extern void EpdAdd3(EpDouble const *epd1, EpDouble const *epd2, EpDouble *epd3);
  68. extern void EpdSubtract(EpDouble *epd1, double value);
  69. extern void EpdSubtract2(EpDouble *epd1, EpDouble const *epd2);
  70. extern void EpdSubtract3(EpDouble const *epd1, EpDouble const *epd2, EpDouble *epd3);
  71. extern void EpdPow2(int n, EpDouble *epd);
  72. extern void EpdPow2Decimal(int n, EpDouble *epd);
  73. extern void EpdNormalize(EpDouble *epd);
  74. extern void EpdNormalizeDecimal(EpDouble *epd);
  75. extern void EpdGetValueAndDecimalExponent(EpDouble const *epd, double *value, int *exponent);
  76. extern int EpdGetExponent(double value);
  77. extern int EpdGetExponentDecimal(double value);
  78. extern void EpdMakeInf(EpDouble *epd, int sign);
  79. extern void EpdMakeZero(EpDouble *epd, int sign);
  80. extern void EpdMakeNan(EpDouble *epd);
  81. extern void EpdCopy(EpDouble const *from, EpDouble *to);
  82. extern int EpdIsInf(EpDouble const *epd);
  83. extern int EpdIsZero(EpDouble const *epd);
  84. extern int EpdIsNan(EpDouble const *epd);
  85. extern int EpdIsNanOrInf(EpDouble const *epd);
  86. extern int IsInfDouble(double value);
  87. extern int IsNanDouble(double value);
  88. extern int IsNanOrInfDouble(double value);
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92. #endif /* EPD_H_ */