📄 fptest.c
字号:
send_message(0, ERROR, "Error: exp(-5)\nExpected: 0.006737946999085 Actual: %1.15f", x); return (1); } } x = exp(-10.0); if (x != 0.000045399929762) { if (x < (0.000045399929762 - DPMARGIN) || x > (0.000045399929762 + DPMARGIN)) { send_message(0, ERROR, "Error: exp(-10)\nExpected: 0.000045399929762 Actual: %1.15f", x); return (1); } } x = exp(log(1.0)); if (x != 1.0000000000000000) { if (x < (1.0000000000000000 - DPMARGIN) || x > (1.0000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: exp(log(1)\nExpected: 1.0000000000000000 Actual: %1.15f", x); return (1); } } x = exp(log(10.0)); if (x != 10.000000000000002) { if (x < (10.000000000000002 - DPMARGIN) || x > (10.000000000000002 + DPMARGIN)) { send_message(0, ERROR, "Error: exp(log(10)\nExpected 10.000000000000002 Actual: %1.15f", x); return (1); } } /* logarithms */ x = log(1.0); if (x != 0.0000000000000000) { if (x < (0.0000000000000000 - DPMARGIN) || x > (0.0000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: log(1)\nExpected: 0.0000000000000000 Actual: %1.15f", x); return (1); } } x = log(2.0); if (x != 0.693147180559945) { if (x < (0.693147180559945 - DPMARGIN) || x > (0.693147180559945 + DPMARGIN)) { send_message(0, ERROR, "Error: log(2)\nExpected: 0.693147180559945 Actual: %1.15f", x); return (1); } } x = log(10.0); if (x != 2.302585092994045) { if (x < (2.302585092994045 - DPMARGIN) || x > (2.302585092994045 + DPMARGIN)) { send_message(0, ERROR, "Error: log(10)\nExpected: 2.302585092994045 Actual: %1.15f", x); return (1); } } x = log(100.0); if (x != 4.605170185988091) { if (x < (4.605170185988091 - DPMARGIN) || x > (4.605170185988091 + DPMARGIN)) { send_message(0, ERROR, "Error: log(100)\nExpected: 4.605170185988091 Actual: %1.15f", x); return (1); } } x = log(exp(0.0)); if (x != 0.0000000000000000) { if (x < (0.0000000000000000 - DPMARGIN) || x > (0.0000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: log(exp(0))\nExpected: 0.0000000000000000 Actual: %1.15f", x); return (1); } } x = log(exp(1.0)); if (x != 1.0000000000000000) { if (x < (1.0000000000000000 - DPMARGIN) || x > (1.0000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: log(exp(1))\nExpected: 1.0000000000000000 Actual: %1.15f", x); return (1); } } x = log(exp(10.0)); if (x != 10.0000000000000000) { if (x < (10.0000000000000000 - DPMARGIN) || x > (10.0000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: log(exp(10))\nExpected: 10.0000000000000000 Actual: %1.15f", x); return (1); } } /* These functions are supported by the 68881 but not the FPA */ x = tan(-(2 * pi)); if (x != -(0.000000000820414)); { if (x < (-(0.000000000820414) - DPMARGIN) || x > (-(0.000000000820414) + DPMARGIN)) { send_message(0, ERROR, "Error: tan(-2pi)\nExpected: -0.000000000820414 Actual: %1.15f", x); return (1); } } x = tan(-(7 * pi) / 4); if (x != 0.999999998564275); { if (x < (0.999999998564275 - DPMARGIN) || x > (0.999999998564275 + DPMARGIN)) { send_message(0, ERROR, "Error: tan(-7pi/4)\nExpected: 0.999999998564275 Actual: %1.15f", x); return (1); } } x = tan(-(5 * pi) / 4); if (x != -(1.000000001025517)); { if (x < (-(1.000000001025517) - DPMARGIN) || x > (-(1.000000001025517) + DPMARGIN)) { send_message(0, ERROR, "Error: tan(-5pi/4)\nExpected: -1.000000001025517 Actual: %1.15f", x); return (1); } } x = tan(-(pi)); if (x != -(0.000000000410207)); { if (x < (-(0.000000000410207) - DPMARGIN) || x > (-(0.000000000410207) + DPMARGIN)) { send_message(0, ERROR, "Error: tan(-pi\nExpected: 0.000000000410207 Actual: %1.15f", x); return (1); } } x = tan(-(3 * pi) / 4); if (x != 0.999999999384690); { if (x < (0.999999999384690 - DPMARGIN) || x > (0.999999999384690 + DPMARGIN)) { send_message(0, ERROR, "Error: tan(-3pi/4)\nExpected: 0.999999999384690 Actual: %1.15f", x); return (1); } } x = tan(-(pi) / 4); if (x != -(1.000000000205103)); { if (x < (-(1.000000000205103) - DPMARGIN) || x > (-(1.000000000205103) + DPMARGIN)) { send_message(0, ERROR, "Error: tan(-pi/4)\nExpected: -1.000000000205103 Actual: %1.15f", x); return (1); } } x = tan(0.0); if (x != 0.000000000000000); { if (x < (0.000000000000000 - DPMARGIN) || x > (0.000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: tan(0.0)\nExpected: 0.000000000000000 Actual: %1.15f", x); return (1); } } x = tan(pi / 4); if (x != 1.000000000205103); { if (x < (1.000000000205103 - DPMARGIN) || x > (1.000000000205103 + DPMARGIN)) { send_message(0, ERROR, "Error: tan(pi / 4)\nExpected: 1.000000000205103 Actual: %1.15f", x); return (1); } } x = tan((3 * pi) / 4); if (x != -0.999999999384690); { if (x < (-(0.999999999384690) - DPMARGIN) || x > (-(0.999999999384690) + DPMARGIN)) { send_message(0, ERROR, "Error: tan(3pi/4)\nExpected: -0.999999999384690 Actual: %1.15f", x); return (1); } } x = tan(pi); if (x != 0.000000000410207); { if (x < (0.000000000410207 - DPMARGIN) || x > (0.000000000410207 + DPMARGIN)) { send_message(0, ERROR, "Error: tan(pi)\nExpected: 0.000000000410207 Actual: %1.15f", x); return (1); } } x = tan((5 * pi) / 4); if (x != 1.000000001025517); { if (x < (1.000000001025517 - DPMARGIN) || x > (1.000000001025517 + DPMARGIN)) { send_message(0, ERROR, "Error: tan(5pi/4)\nExpected: 1.000000001025517 Actual: %1.15f", x); return (1); } } x = tan((7 * pi) / 4); if (x != -0.999999998564275); { if (x < (-(0.999999998564275) - DPMARGIN) || x > (-(0.999999998564275) + DPMARGIN)) { send_message(0, ERROR, "Error: tan(7pi/4)\nExpected: -0.999999998564275 Actual: %1.15f", x); return (1); } } x = tan((2 * pi)); if (x != 0.000000000820414); { if (x < (0.000000000820414 - DPMARGIN) || x > (0.000000000820414 + DPMARGIN)) { send_message(0, ERROR, "Error: tan(2pi)\nExpected: 0.000000000820414 Actual: %1.15f", x); return (1); } } x = sqrt(0.0); if (x != 0.000000000000000) { if (x < (0.000000000000000 - DPMARGIN) || x > (0.000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: sqrt(0)\nExpected: 0.000000000000000 Actual: %1.15f", x); return (1); } } x = sqrt(1.0); if (x != 1.000000000000000) { if (x < (1.000000000000000 - DPMARGIN) || x > (1.000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: sqrt(1)\nExpected: 1.000000000000000 Actual: %1.15f", x); return (1); } } x = sqrt(4.0); if (x != 2.000000000000000) { if (x < (2.000000000000000 - DPMARGIN) || x > (2.000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: sqrt(4)\nExpected: 2.000000000000000 Actual: %1.15f", x); return (1); } } x = sqrt(9.0); if (x != 3.000000000000000) { if (x < (3.000000000000000 - DPMARGIN) || x > (3.000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: sqrt(9)\nExpected: 3.000000000000000 Actual: %1.15f", x); return (1); } } x = sqrt(16.0); if (x != 4.000000000000000) { if (x < (4.000000000000000 - DPMARGIN) || x > (4.000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: sqrt(16)\nExpected: 4.000000000000000 Actual: %1.15f", x); return (1); } } x = sqrt(25.0); if (x != 5.000000000000000) { if (x < (5.000000000000000 - DPMARGIN) || x > (5.000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: sqrt(25)\nExpected: 5.000000000000000 Actual: %1.15f", x); return (1); } } x = sqrt(36.0); if (x != 6.000000000000000) { if (x < (6.000000000000000 - DPMARGIN) || x > (6.000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: sqrt(36)\nExpected: 6.000000000000000 Actual: %1.15f", x); return (1); } } x = sqrt(49.0); if (x != 7.000000000000000) { if (x < (7.000000000000000 - DPMARGIN) || x > (7.000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: sqrt(49)\nExpected: 7.000000000000000 Actual: %1.15f", x); return (1); } } x = sqrt(64.0); if (x != 8.000000000000000) { if (x < (8.000000000000000 - DPMARGIN) || x > (8.000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: sqrt(64)\nExpected: 8.000000000000000 Actual: %1.15f", x); return (1); } } x = sqrt(81.0); if (x != 9.000000000000000) { if (x < (9.000000000000000 - DPMARGIN) || x > (9.000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: sqrt(81)\nExpected: 9.000000000000000 Actual: %1.15f", x); return (1); } } x = sqrt(100.0); if (x != 10.000000000000000) { if (x < (10.000000000000000 - DPMARGIN) || x > (10.000000000000000 + DPMARGIN)) { send_message(0, ERROR, "Error: sqrt(100)\nExpected: 10.000000000000000 Actual: %1.15f", x); return (1); } } if (quick_test) break; if (!quick_test && (dpfpa % 25) == 0) sleep(1); } /* end of for loop */ return (0);}float_exp(){ send_message(-FP_EXCEPTION_ERROR, FATAL, "Floating point exception interrupt.");}clean_up(){}#ifdef sun3probe881(){ int val; int eeopen; int pointer; int seek_ok; int nbytes; long offset; unsigned char ee_buffer[8]; char buf; int i; offset = 0x0000BC; pointer = L_SET; eeopen = open("/dev/eeprom", O_RDONLY); send_message(0, DEBUG, "eeopen = %d", eeopen); if (eeopen < 0) { send_message(1, ERROR, "Cannot open /dev/eeprom "); } send_message(0, DEBUG, "passed open"); for (i = 0; i < 14; i++) { seek_ok = lseek(eeopen, offset, pointer); send_message(0, DEBUG, "seek_ok = %x", seek_ok); if (seek_ok == -1) { send_message(1, ERROR, "lseek failed"); exit(0); } send_message(0, DEBUG, "passed lseek"); nbytes = 8; val = read(eeopen, ee_buffer, nbytes); send_message(0, DEBUG, "val = %d", val); if (val == -1) { send_message(1, ERROR, "read failed"); exit(0); } send_message(0, DEBUG, "\ ee_buffer[0] = %x\n\ ee_buffer[1] = %x\n\ ee_buffer[2] = %x\n\ ee_buffer[3] = %x\n\ ee_buffer[4] = %x\n\ ee_buffer[5] = %x\n\ ee_buffer[6] = %x\n\ ee_buffer[7] = %x\n\ passed read.", ee_buffer[0], ee_buffer[1], ee_buffer[2], ee_buffer[3], ee_buffer[4], ee_buffer[5], ee_buffer[6], ee_buffer[7]); if (ee_buffer[0] == 0xFF) { send_message(0, CONSOLE, "Could not find configuration for MC68881 in EEPROM\n"); return (-1); } if (ee_buffer[0] == 0x01) { buf = ee_buffer[2]; send_message(0, DEBUG, "buf = %x", buf); buf = buf & 0x01; send_message(0, DEBUG, "buf = %x", buf); if (buf == 1) return (1); return (0); } offset = 0; pointer = L_INCR; if (i == 13) { send_message(1, ERROR, " System configuration of EEPROM is wrong.\n Expected to find FF which represents the end of the configuration."); return (-1); } }}#endifint process_fpatest_args(argv, arrcount)char *argv[];int arrcount;{ if (argv[arrcount][0] == 'e') { simulate_error = atoi(&argv[arrcount][1]); if (simulate_error > 0 && simulate_error < 8) return (TRUE); } else return (FALSE); return (TRUE);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -