00001 #include <ansidecl.h>
00002
00003 #ifdef __IEEE_BIG_ENDIAN
00004
00005 typedef union
00006 {
00007 double value;
00008 struct
00009 {
00010 unsigned int sign : 1;
00011 unsigned int exponent: 11;
00012 unsigned int fraction0:4;
00013 unsigned int fraction1:16;
00014 unsigned int fraction2:16;
00015 unsigned int fraction3:16;
00016
00017 } number;
00018 struct
00019 {
00020 unsigned int sign : 1;
00021 unsigned int exponent: 11;
00022 unsigned int quiet:1;
00023 unsigned int function0:3;
00024 unsigned int function1:16;
00025 unsigned int function2:16;
00026 unsigned int function3:16;
00027 } nan;
00028 struct
00029 {
00030 unsigned long msw;
00031 unsigned long lsw;
00032 } parts;
00033 long aslong[2];
00034 } __ieee_double_shape_type;
00035
00036 #endif
00037
00038 #ifdef __IEEE_LITTLE_ENDIAN
00039
00040 typedef union
00041 {
00042 double value;
00043 struct
00044 {
00045 #ifdef __SMALL_BITFIELDS
00046 unsigned int fraction3:16;
00047 unsigned int fraction2:16;
00048 unsigned int fraction1:16;
00049 unsigned int fraction0: 4;
00050 #else
00051 unsigned int fraction1:32;
00052 unsigned int fraction0:20;
00053 #endif
00054 unsigned int exponent :11;
00055 unsigned int sign : 1;
00056 } number;
00057 struct
00058 {
00059 #ifdef __SMALL_BITFIELDS
00060 unsigned int function3:16;
00061 unsigned int function2:16;
00062 unsigned int function1:16;
00063 unsigned int function0:3;
00064 #else
00065 unsigned int function1:32;
00066 unsigned int function0:19;
00067 #endif
00068 unsigned int quiet:1;
00069 unsigned int exponent: 11;
00070 unsigned int sign : 1;
00071 } nan;
00072 struct
00073 {
00074 unsigned long lsw;
00075 unsigned long msw;
00076 } parts;
00077
00078 long aslong[2];
00079
00080 } __ieee_double_shape_type;
00081
00082 #endif
00083
00084 #ifdef __IEEE_BIG_ENDIAN
00085 typedef union
00086 {
00087 float value;
00088 struct
00089 {
00090 unsigned int sign : 1;
00091 unsigned int exponent: 8;
00092 unsigned int fraction0: 7;
00093 unsigned int fraction1: 16;
00094 } number;
00095 struct
00096 {
00097 unsigned int sign:1;
00098 unsigned int exponent:8;
00099 unsigned int quiet:1;
00100 unsigned int function0:6;
00101 unsigned int function1:16;
00102 } nan;
00103 long p1;
00104
00105 } __ieee_float_shape_type;
00106 #endif
00107
00108 #ifdef __IEEE_LITTLE_ENDIAN
00109 typedef union
00110 {
00111 float value;
00112 struct
00113 {
00114 unsigned int fraction0: 7;
00115 unsigned int fraction1: 16;
00116 unsigned int exponent: 8;
00117 unsigned int sign : 1;
00118 } number;
00119 struct
00120 {
00121 unsigned int function1:16;
00122 unsigned int function0:6;
00123 unsigned int quiet:1;
00124 unsigned int exponent:8;
00125 unsigned int sign:1;
00126 } nan;
00127 long p1;
00128
00129 } __ieee_float_shape_type;
00130 #endif
00131
00132 #if defined(__IEEE_BIG_ENDIAN) || defined(__IEEE_LITTLE_ENDIAN)
00133
00134 double
00135 copysign (x, y)
00136 double x, y;
00137 {
00138 __ieee_double_shape_type a,b;
00139 b.value = y;
00140 a.value = x;
00141 a.number.sign =b.number.sign;
00142 return a.value;
00143 }
00144
00145 #else
00146
00147 double
00148 copysign (x, y)
00149 double x, y;
00150 {
00151 if ((x < 0 && y > 0) || (x > 0 && y < 0))
00152 return -x;
00153 return x;
00154 }
00155
00156 #endif