math.inc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2000 by Jonas Maebe and other members of the
  5. Free Pascal development team
  6. Implementation of mathamatical Routines (only for real)
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {$ifdef unused}
  14. {****************************************************************************
  15. Int to real helpers
  16. ****************************************************************************}
  17. const
  18. longint_to_real_helper: int64 = $4330000080000000;
  19. cardinal_to_real_helper: int64 = $430000000000000;
  20. int_to_real_factor: double = double(high(cardinal))+1.0;
  21. {****************************************************************************
  22. EXTENDED data type routines
  23. ****************************************************************************}
  24. {$define FPC_SYSTEM_HAS_PI}
  25. function pi : double;[internproc:in_pi];
  26. {$define FPC_SYSTEM_HAS_ABS}
  27. function abs(d : extended) : extended;[internproc:in_abs_extended];
  28. {$define FPC_SYSTEM_HAS_SQR}
  29. function sqr(d : extended) : extended;[internproc:in_sqr_extended];
  30. {$define FPC_SYSTEM_HAS_SQRT}
  31. function sqrt(d : extended) : extended;[internproc:in_sqrt_extended];
  32. {
  33. function arctan(d : extended) : extended;[internconst:in_arctan_extended];
  34. begin
  35. runerror(207);
  36. end;
  37. function ln(d : extended) : extended;[internconst:in_ln_extended];
  38. begin
  39. runerror(207);
  40. end;
  41. function sin(d : extended) : extended;[internconst: in_sin_extended];
  42. begin
  43. runerror(207);
  44. end;
  45. function cos(d : extended) : extended;[internconst:in_cos_extended];
  46. begin
  47. runerror(207);
  48. end;
  49. function exp(d : extended) : extended;[internconst:in_const_exp];
  50. begin
  51. runerror(207);
  52. end;
  53. function frac(d : extended) : extended;[internconst:in_const_frac];
  54. begin
  55. runerror(207);
  56. end;
  57. }
  58. { define FPC_SYSTEM_HAS_INT}
  59. {$warning FIX ME}
  60. function int(d : extended) : extended;[internconst:in_const_int];
  61. begin
  62. runerror(207);
  63. end;
  64. { define FPC_SYSTEM_HAS_TRUNC}
  65. {$warning FIX ME}
  66. function trunc(d : extended) : int64;{assembler;}[internconst:in_const_trunc];
  67. { input: d in fr1 }
  68. { output: result in r3 }
  69. {assembler;}
  70. var
  71. temp: packed record
  72. case byte of
  73. 0: (l1,l2: longint);
  74. 1: (d: double);
  75. end;
  76. begin{asm}
  77. { fctiwz f1,f1
  78. stfd f1,temp
  79. lwz r3,temp
  80. lwz r4,4+temp}
  81. end{ ['R3','F1']};
  82. { define FPC_SYSTEM_HAS_ROUND}
  83. function round(d : extended) : int64;[internconst:in_const_round, external name 'FPC_ROUND'];
  84. function fpc_round(d : extended) : int64;[public, alias:'FPC_ROUND'];compilerproc;
  85. begin
  86. end;
  87. {$endif}
  88. {
  89. $Log$
  90. Revision 1.8 2004-01-06 21:33:38 peter
  91. * remove generic functions
  92. Revision 1.7 2003/09/14 15:02:24 peter
  93. * remove int64 to double helpers
  94. Revision 1.6 2003/09/02 17:41:49 peter
  95. * updated for int64 to double
  96. Revision 1.5 2003/09/01 20:46:32 peter
  97. * new dummies
  98. Revision 1.4 2003/04/23 21:28:21 peter
  99. * fpc_round added, needed for int64 currency
  100. Revision 1.3 2003/01/22 20:45:15 mazen
  101. * making math code in RTL compiling.
  102. *NB : This does NOT mean necessary that it will generate correct code!
  103. Revision 1.2 2003/01/20 22:21:36 mazen
  104. * many stuff related to RTL fixed
  105. Revision 1.1 2002/12/24 21:30:20 mazen
  106. - some writeln(s) removed in compiler
  107. + many files added to RTL
  108. * some errors fixed in RTL
  109. Revision 1.14 2002/11/28 11:04:16 olle
  110. * macos: refs to globals in begin{asm} adapted to macos
  111. Revision 1.13 2002/10/21 18:08:28 jonas
  112. * round has int64 instead of longint result
  113. Revision 1.12 2002/09/08 13:00:21 jonas
  114. * made pi an internproc instead of internconst
  115. Revision 1.11 2002/09/07 16:01:26 peter
  116. * old logs removed and tabs fixed
  117. Revision 1.10 2002/08/18 22:11:10 florian
  118. * fixed remaining assembler errors
  119. Revision 1.9 2002/08/18 21:37:48 florian
  120. * several errors in inline assembler fixed
  121. Revision 1.8 2002/08/10 17:14:36 jonas
  122. * various fixes, mostly changing the names of the modifies registers to
  123. upper case since that seems to be required by the compiler
  124. Revision 1.7 2002/07/31 16:58:12 jonas
  125. * fixed conversion from int64/qword to double errors
  126. Revision 1.6 2002/07/29 21:28:17 florian
  127. * several fixes to get further with linux/ppc system unit compilation
  128. Revision 1.5 2002/07/28 21:39:29 florian
  129. * made abs a compiler proc if it is generic
  130. Revision 1.4 2002/07/28 20:43:49 florian
  131. * several fixes for linux/powerpc
  132. * several fixes to MT
  133. }