home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1990 / 12 / praxis / sincos.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-18  |  2.5 KB  |  79 lines

  1. //------<<< SINCOS.C ANFANG >>>-----------------------------
  2. #include<dos.h>
  3. #include<float.h>
  4. #include<stdio.h>
  5.  
  6. //---- Typendeklarationen ----------------------------------
  7. typedef double dword;
  8. typedef unsigned char byte;
  9. typedef unsigned int word;
  10.  
  11. /*             ---------
  12.  --------------- SINUS -------------------------------------
  13.  -             ---------                                   -
  14.  -       Autor: Ulrich Schmitz & toolbox 1990              -
  15.  -    Compiler: Turbo C++                                  -
  16.  -      AUFRUF: dword sinus(dword winkel);                 -
  17.  -     EINGABE: 4-Byte Winkelwert.                         -
  18.  -    RÜCKGABE: Sinus (RAD) des Winkelwertes als dword     -
  19.  -              bzw. float oder long-Wert.                 -
  20.  -    Funktion: Berechnet den Sinus zu einem vorgegebenen  -
  21.  -              Winkel.                                    -
  22.  -----------------------------------------------------------
  23. */
  24.  
  25. dword sinus(dword Winkel)
  26. {
  27.   dword Ergebnis;
  28. // Coprozessor-Befehle erfordern 80x87 Arithmetikprozessor *
  29.   asm FINIT;                 // Coprozessor initialisieren
  30.   asm FLD Winkel;         // 32-Bit-Operand auf Stack
  31.   asm FPTAN;
  32.   asm FLD ST(1);
  33.   asm FMUL ST,ST;
  34.   asm FXCH;
  35.   asm FMUL ST,ST;
  36.   asm FADD;
  37.   asm FSQRT;
  38.   asm FDIV;
  39.   asm FST Ergebnis;           // Ergebnis zurückgeben
  40.  return Ergebnis;
  41. }
  42.  
  43.  
  44.  
  45. /*             -----------
  46.  --------------- COSINUS -----------------------------------
  47.  -             -----------                                 -
  48.  -       Autor: Ulrich Schmitz & toolbox 1990              -
  49.  -    Compiler: Turbo C++                                  -
  50.  -      AUFRUF: dword cosinus(dword Winkel)                -
  51.  -     EINGABE: Winkelwert als Doppelwort (4 Byte)         -
  52.  -    RÜCKGABE: Cosinus (RAD) des Winkels als dword        -
  53.  -              bzw. float oder long-Wert.                 -
  54.  -    Funktion: Berechnet den Cosinus zu einem gegebenem   -
  55.  -              Winkel.                                    -
  56.  -----------------------------------------------------------
  57. */
  58.  
  59. dword cosinus(dword Winkel)
  60. {
  61.  dword Ergebnis;
  62. // Coprozessor-Befehle erfordern 80x87 Arithmetikprozessor *
  63.   asm FINIT;
  64.   asm FLD Winkel;
  65.   asm FPTAN;
  66.   asm FLD ST(1);
  67.   asm FMUL ST,ST;
  68.   asm FXCH;
  69.   asm FMUL ST,ST;
  70.   asm FDIV;
  71.   asm FLD1;
  72.   asm FADD;
  73.   asm FSQRT;
  74.   asm FLD1;
  75.   asm FDIVR;
  76.   asm FST Ergebnis;
  77.  return Ergebnis;
  78. }
  79. //------<<< SINCOS.C ENDE >>>-------------------------------