home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / pmlsrc23.zoo / pmlsrc / sign.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-19  |  2.0 KB  |  105 lines

  1. /************************************************************************
  2.  *                                    *
  3.  * mjr: provided assembler version for all system configurations    *
  4.  * 15.12.92                                    *
  5.  ************************************************************************
  6.  *                                    *
  7.  *                N O T I C E                *
  8.  *                                    *
  9.  *            Copyright Abandoned, 1987, Fred Fish        *
  10.  *                                    *
  11.  *    This previously copyrighted work has been placed into the    *
  12.  *    public domain by the author (Fred Fish) and may be freely used    *
  13.  *    for any purpose, private or commercial.  I would appreciate    *
  14.  *    it, as a courtesy, if this notice is left in all copies and    *
  15.  *    derivative works.  Thank you, and enjoy...            *
  16.  *                                    *
  17.  *    The author makes no warranty of any kind with respect to this    *
  18.  *    product and explicitly disclaims any implied warranties of    *
  19.  *    merchantability or fitness for any particular purpose.        *
  20.  *                                    *
  21.  ************************************************************************
  22.  */
  23.  
  24.  
  25. /*
  26.  *  FUNCTION
  27.  *
  28.  *    copysign   transfer of sign
  29.  *
  30.  *  KEY WORDS
  31.  *
  32.  *    sign
  33.  *    machine independent routines
  34.  *    math libraries
  35.  *
  36.  *  DESCRIPTION
  37.  *
  38.  *    Returns first argument with same sign as second argument.
  39.  *
  40.  *  USAGE
  41.  *
  42.  *    double copysign (x, y)
  43.  *    double x;
  44.  *    double y;
  45.  *
  46.  *  PROGRAMMER
  47.  *
  48.  *    Fred Fish
  49.  *    Tempe, Az 85281
  50.  *    (602) 966-8871
  51.  *
  52.  */
  53.  
  54. #include <stdio.h>
  55. #include <math.h>
  56. #include "pml.h"
  57.  
  58.  
  59. #if OLD
  60.  
  61. double copysign (x, y)
  62. double x;
  63. double y;
  64. {
  65.     double rtnval;
  66.     
  67.     ENTER ("copysign");
  68.     DEBUG4 ("copysignin", "args %le %le", x, y);
  69.     if (x >= 0.0) {
  70.     if (y >= 0.0) {
  71.         rtnval = x;
  72.     } else {
  73.         rtnval = -x;
  74.     }
  75.     } else {
  76.     if (y < 0.0) {
  77.         rtnval = x;
  78.     } else {
  79.         rtnval = -x;
  80.     }
  81.     }
  82.     DEBUG3 ("copysignout", "result %le", rtnval);
  83.     LEAVE ();
  84.     return (rtnval);
  85. }
  86.  
  87. #else    OLD     /* mjr: assembler version for  all machines */
  88. __asm("
  89. .text
  90. .even
  91. .globl _copysign
  92.  
  93. _copysign:
  94.     moveml    a7@(4),d0-d1
  95.     btst    #31,a7@(12)
  96.     beq    clear
  97.     bset    #31,d0
  98.     rts
  99. clear:
  100.     bclr    #31,d0
  101.     rts
  102. ");    /* end asm    */
  103.  
  104. #endif    OLD
  105.