Annotation of OpenXM_contrib2/asir2000/builtin/round.c, Revision 1.1
1.1 ! noro 1: #define INTERVAL
! 2: #include "ca.h"
! 3: #include "parse.h"
! 4: #include "interval.h"
! 5:
! 6: void Padd_pinf(),Padd_minf();
! 7: void Psub_pinf(),Psub_minf();
! 8: void Pmul_pinf(),Pmul_minf();
! 9: void Pdiv_pinf(),Pdiv_minf();
! 10:
! 11: struct ftab round_tab[] = {
! 12: {"add_pinf",Padd_pinf,2},
! 13: {"add_minf",Padd_minf,2},
! 14: {"sub_pinf",Psub_pinf,2},
! 15: {"sub_minf",Psub_minf,2},
! 16: {"mul_pinf",Pmul_pinf,2},
! 17: {"mul_minf",Pmul_minf,2},
! 18: {"div_pinf",Pdiv_pinf,2},
! 19: {"div_minf",Pdiv_minf,2},
! 20: {0,0,0},
! 21: };
! 22:
! 23: void Padd_pinf(NODE arg,Real *rp)
! 24: {
! 25: Real a,b,r;
! 26: double c;
! 27:
! 28: a = (Real)ARG0(arg);
! 29: b = (Real)ARG1(arg);
! 30: if ( !a )
! 31: *rp = b;
! 32: else if ( !b )
! 33: *rp = a;
! 34: else {
! 35: FPPLUSINF
! 36: c = BDY(a)+BDY(b);
! 37: FPNEAREST
! 38: MKReal(c,r);
! 39: *rp = r;
! 40: }
! 41: }
! 42:
! 43: void Padd_minf(NODE arg,Real *rp)
! 44: {
! 45: Real a,b,r;
! 46: double c;
! 47:
! 48: a = (Real)ARG0(arg);
! 49: b = (Real)ARG1(arg);
! 50: if ( !a )
! 51: *rp = b;
! 52: else if ( !b )
! 53: *rp = a;
! 54: else {
! 55: FPMINUSINF
! 56: c = BDY(a)+BDY(b);
! 57: FPNEAREST
! 58: MKReal(c,r);
! 59: *rp = r;
! 60: }
! 61: }
! 62:
! 63: void Psub_pinf(NODE arg,Real *rp)
! 64: {
! 65: Real a,b,r;
! 66: double c;
! 67:
! 68: a = (Real)ARG0(arg);
! 69: b = (Real)ARG1(arg);
! 70: if ( !a ) {
! 71: if ( !b )
! 72: *rp = 0;
! 73: else {
! 74: c = -BDY(b);
! 75: MKReal(c,r);
! 76: *rp = r;
! 77: }
! 78: } else if ( !b )
! 79: *rp = a;
! 80: else {
! 81: FPPLUSINF
! 82: c = BDY(a)-BDY(b);
! 83: FPNEAREST
! 84: MKReal(c,r);
! 85: *rp = r;
! 86: }
! 87: }
! 88:
! 89: void Psub_minf(NODE arg,Real *rp)
! 90: {
! 91: Real a,b,r;
! 92: double c;
! 93:
! 94: a = (Real)ARG0(arg);
! 95: b = (Real)ARG1(arg);
! 96: if ( !a ) {
! 97: if ( !b )
! 98: *rp = 0;
! 99: else {
! 100: c = -BDY(b);
! 101: MKReal(c,r);
! 102: *rp = r;
! 103: }
! 104: } else if ( !b )
! 105: *rp = a;
! 106: else {
! 107: FPMINUSINF
! 108: c = BDY(a)-BDY(b);
! 109: FPNEAREST
! 110: MKReal(c,r);
! 111: *rp = r;
! 112: }
! 113: }
! 114:
! 115: void Pmul_pinf(NODE arg,Real *rp)
! 116: {
! 117: Real a,b,r;
! 118: double c;
! 119:
! 120: a = (Real)ARG0(arg);
! 121: b = (Real)ARG1(arg);
! 122: if ( !a || !b )
! 123: *rp = 0;
! 124: else {
! 125: FPPLUSINF
! 126: c = BDY(a)*BDY(b);
! 127: FPNEAREST
! 128: MKReal(c,r);
! 129: *rp = r;
! 130: }
! 131: }
! 132:
! 133: void Pmul_minf(NODE arg,Real *rp)
! 134: {
! 135: Real a,b,r;
! 136: double c;
! 137:
! 138: a = (Real)ARG0(arg);
! 139: b = (Real)ARG1(arg);
! 140: if ( !a || !b )
! 141: *rp = 0;
! 142: else {
! 143: FPMINUSINF
! 144: c = BDY(a)*BDY(b);
! 145: FPNEAREST
! 146: MKReal(c,r);
! 147: *rp = r;
! 148: }
! 149: }
! 150:
! 151: void Pdiv_pinf(NODE arg,Real *rp)
! 152: {
! 153: Real a,b,r;
! 154: double c;
! 155:
! 156: a = (Real)ARG0(arg);
! 157: b = (Real)ARG1(arg);
! 158: if ( !b )
! 159: error("div_pinf : division by 0");
! 160: else if ( !a )
! 161: *rp = 0;
! 162: else {
! 163: FPPLUSINF
! 164: c = BDY(a)/BDY(b);
! 165: FPNEAREST
! 166: MKReal(c,r);
! 167: *rp = r;
! 168: }
! 169: }
! 170:
! 171: void Pdiv_minf(NODE arg,Real *rp)
! 172: {
! 173: Real a,b,r;
! 174: double c;
! 175:
! 176: a = (Real)ARG0(arg);
! 177: b = (Real)ARG1(arg);
! 178: if ( !b )
! 179: error("div_pinf : division by 0");
! 180: else if ( !a )
! 181: *rp = 0;
! 182: else {
! 183: FPMINUSINF
! 184: c = BDY(a)/BDY(b);
! 185: FPNEAREST
! 186: MKReal(c,r);
! 187: *rp = r;
! 188: }
! 189: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>