mathh.inc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Florian Klaempfl,
  4. member of the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. { i386 FPU Controlword }
  12. {$if defined(cpui8086) or defined(cpui386) or defined(cpux86_64)}
  13. const
  14. Default8087CW : word = $1332;
  15. procedure Set8087CW(cw:word);
  16. function Get8087CW:word;
  17. {$ifndef cpui8086}
  18. procedure SetSSECSR(w : dword);
  19. function GetSSECSR : dword;
  20. {$endif not cpui8086}
  21. {$endif}
  22. type
  23. TFPURoundingMode = (rmNearest, rmDown, rmUp, rmTruncate);
  24. TFPUPrecisionMode = (pmSingle, pmReserved, pmDouble, pmExtended);
  25. TFPUException = (exInvalidOp, exDenormalized, exZeroDivide,
  26. exOverflow, exUnderflow, exPrecision);
  27. TFPUExceptionMask = set of TFPUException;
  28. const
  29. {*
  30. -------------------------------------------------------------------------------
  31. Software IEC/IEEE floating-point exception flags.
  32. -------------------------------------------------------------------------------
  33. *}
  34. float_flag_invalid = exInvalidOp;
  35. float_flag_denormal = exDenormalized;
  36. float_flag_divbyzero = exZeroDivide;
  37. float_flag_overflow = exOverflow;
  38. float_flag_underflow = exUnderflow;
  39. float_flag_inexact = exPrecision;
  40. {*
  41. -------------------------------------------------------------------------------
  42. Software IEC/IEEE floating-point rounding mode.
  43. -------------------------------------------------------------------------------
  44. *}
  45. float_round_nearest_even = rmNearest;
  46. float_round_down = rmDown;
  47. float_round_up = rmUp;
  48. float_round_to_zero = rmTruncate;
  49. {$ifdef FPC_HAS_FEATURE_THREADING}
  50. ThreadVar
  51. {$else FPC_HAS_FEATURE_THREADING}
  52. Var
  53. {$endif FPC_HAS_FEATURE_THREADING}
  54. softfloat_exception_mask : TFPUExceptionMask;
  55. softfloat_exception_flags : TFPUExceptionMask;
  56. softfloat_rounding_mode : TFPURoundingMode;
  57. procedure float_raise(i: TFPUException);
  58. procedure float_raise(i: TFPUExceptionMask);
  59. {$ifdef cpui386}
  60. {$define INTERNMATH}
  61. {$endif}
  62. {$ifndef INTERNMATH}
  63. {$ifdef FPC_USE_LIBC}
  64. {$ifdef SYSTEMINLINE}
  65. {$define MATHINLINE}
  66. {$endif}
  67. {$endif}
  68. {$endif}
  69. function pi : ValReal;[internproc:fpc_in_pi_real];
  70. function abs(d : ValReal) : ValReal;[internproc:fpc_in_abs_real];
  71. function sqr(d : ValReal) : ValReal;[internproc:fpc_in_sqr_real];
  72. function sqrt(d : ValReal) : ValReal;[internproc:fpc_in_sqrt_real];
  73. function arctan(d : ValReal) : ValReal;[internproc:fpc_in_arctan_real];
  74. function ln(d : ValReal) : ValReal;[internproc:fpc_in_ln_real];
  75. function sin(d : ValReal) : ValReal;[internproc:fpc_in_sin_real];
  76. function cos(d : ValReal) : ValReal;[internproc:fpc_in_cos_real];
  77. function exp(d : ValReal) : ValReal;[internproc:fpc_in_exp_real];
  78. function round(d : ValReal) : int64;[internproc:fpc_in_round_real];
  79. function frac(d : ValReal) : ValReal;[internproc:fpc_in_frac_real];
  80. function int(d : ValReal) : ValReal;[internproc:fpc_in_int_real];
  81. function trunc(d : ValReal) : int64;[internproc:fpc_in_trunc_real];
  82. {$ifdef SUPPORT_EXTENDED}
  83. function FPower10(val: Extended; Power: Longint): Extended;
  84. {$endif SUPPORT_EXTENDED}
  85. type
  86. real48 = array[0..5] of byte;
  87. {$ifdef SUPPORT_DOUBLE}
  88. function Real2Double(r : real48) : double;
  89. operator := (b:real48) d:double;
  90. {$endif}
  91. {$ifdef SUPPORT_EXTENDED}
  92. operator := (b:real48) e:extended;
  93. {$endif SUPPORT_EXTENDED}