⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fptest.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
	ans = (a + b);	if (ans != 2.222100000000000) {	    if (ans < (2.222100000000000 - DPMARGIN) ||				ans > (2.222100000000000 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a + b\nExpected: 2.222100000000000    	Actual: %1.15f", ans);		return (1);	    }	}	ans = (a - b);	if (ans != 0.246899999999999) {	    if (ans < (0.246899999999999 - DPMARGIN) ||				ans > (0.246899999999999 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a - b\nExpected: 0.246899999999999    	Actual: %1.15f", ans);		return (1);	    }	}	ans = a * b;	if (ans != 1.219192199999999) {	    if (ans < (1.219192199999999 - DPMARGIN) ||				ans > (1.219192199999999 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a * b\nExpected: 1.219192199999999    	Actual: %1.15f", ans);		return (1);	    }	}	ans = a / b;	if (ans != 1.249999999999999) {	    if (ans < (1.249999999999999 - DPMARGIN) ||				ans > (1.249999999999999 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a / b\nExpected: 1.249999999999999	Actual: %1.15f", ans);		return (1);	    }	}	ans = a + (a - b);	if (ans != 1.481399999999999) {	    if (ans < (1.481399999999999 - DPMARGIN) ||				ans > (1.481399999999999 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a + (a - b)\nExpected: 1.481399999999999 	Actual: %1.15f", ans);		return (1);	    }	}	ans = a - (a + b);	if (ans != -(0.987600000000000)) {	    if (ans < (-(0.987600000000000) - DPMARGIN) ||				ans > (-(0.987600000000000) + DPMARGIN)) {		send_message(0, ERROR, "Error:  a - (a + b)\nExpected: -0.987600000000000 	Actual: %1.15f", ans);		return (1);	    }	}	ans = a + (a * b);	if (ans != 2.453692200000000) {	    if (ans < (2.453692200000000 - DPMARGIN) ||				ans > (2.453692200000000 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a + (a * b)\nExpected: 2.453692200000000  	Actual: %1.15f", ans);		return (1);	    }	}	ans = a - (a * b);	if (ans != 0.015307800000000) {	    if (ans < (0.015307800000000 - DPMARGIN) || 				ans > (0.015307800000000 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a - (a * b)\nExpected: 0.015307800000000    	Actual: %1.15f", ans);		return (1);	    }	}	ans = a + (a / b);	if (ans != 2.484500000000000) {	    if (ans < (2.484500000000000 - DPMARGIN) || 				ans > (2.484500000000000 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a + (a / b)\nExpected: 2.484500000000000   	 Actual: %1.15f", ans);		return (1);	    }	}	ans = a - (a / b);	if (ans != -(0.015499999999999)) {	    if (ans < (-(0.015499999999999) - DPMARGIN) || 				ans > (-(0.015499999999999) + DPMARGIN)) {		send_message(0, ERROR, "Error:  a - (a / b)\nExpected: -0.015499999999999   	 Actual: %1.15f", ans);		return (1);	    }	}	ans = a * (a + b);	if (ans != 2.743182449999999) {	    if (ans < (2.743182449999999 - DPMARGIN) || 				ans > (2.743182449999999 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a * (a + b)\nExpected: 2.743182449999999   	 Actual: %1.15f", ans);		return (1);	    }	}	ans = a * (a - b);	if (ans != 0.304798049999999) {	    if (ans < (0.304798049999999 - DPMARGIN) || 				ans > (0.304798049999999 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a * (a - b)\nExpected: 0.304798049999999   	 Actual: %1.15f", ans);		return (1);	    }	}	ans = a / (a + b);	if (ans != 0.555555555555555) {	    if (ans < (0.555555555555555 - DPMARGIN) || 				ans > (0.555555555555555 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a / (a + b)\nExpected: 0.555555555555555      Actual: %1.15f", ans);		return (1);	    }	}	ans = a / (a - b);	if (ans != 5.000000000000002) {	    if (ans < (5.000000000000002 - DPMARGIN) || 				ans > (5.000000000000002 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a / (a - b)\nExpected: 5.000000000000002   	 Actual: %1.15f", ans);		return (1);	    }	}	ans = a * (a / b);	if (ans != 1.543124999999999) {	    if (ans < (1.543124999999999 - DPMARGIN) || 				ans > (1.543124999999999 + DPMARGIN)) {		send_message(0, ERROR, "Error:  a * (a / b)\nExpected: 1.543124999999999   	 Actual: %1.15f)", ans);		return (1);	    }	}	ans = a / (a * b);	if (ans != 1.012555690562980) {	    if (ans < (1.012555690562980 - DPMARGIN) || 				ans > (1.012555690562980 + DPMARGIN)) {		send_message(0, ERROR, "Error:   a / (a * b)\nExpected: 1.0125555690562980	 Actual: %1.15f)", ans);		return (1);	    }	}	/* Start Double Precision test of trg functions */	/* sin of values in the range of -2pi to +2pi   */	result = sin(-(pi * 2));	if (result != -(0.000000000820413)) {	    if (result < (-(0.000000000820413) - DPMARGIN) || 				result > (-(0.000000000820413) + DPMARGIN)) {		send_message(0, ERROR, "Error:  sin(-2pi)\nExpected: -0.000000000820413 Actual: %1.15f", result);		return (1);	    }	}	result = sin((pi * (-3)) / 2);	if (result != 1.0000000000000000) {	    if (result < (1.0000000000000000 - DPMARGIN) || 				result > (-0.000000000000000 + DPMARGIN)) {		send_message(0, ERROR, "Error: sin(-3pi/2)\nExpected: 1.0000000000000000 Actual: %1.15f", result);		return (1);	    }	}	result = sin(-(pi));	if (result != 0.000000000410206) {	    if (result < (0.000000000410206 - DPMARGIN) || 				result > (0.00000000410206 + DPMARGIN)) {		send_message(0, ERROR, "Error: sin(-pi)\nExpected: 0.000000000410206 Actual: %1.15f", result);		return (1);	    }	}	result = sin(-(pi / 2));	if (result != -(1.0000000000000000)) {	    if (result < (-(1.0000000000000000) - DPMARGIN) || 				result > (-(1.0000000000000000) + DPMARGIN)) {		send_message(0, ERROR, "Error: sin(-pi/2)\nExpected: -1.0000000000000000 Actual: %1.15f", result);		return (1);	    }	}	result = sin(0);	if (result != (0.0000000000000000)) {	    if (result < (0.0000000000000000 - DPMARGIN) || 				result > (0.000000000000000 + DPMARGIN)) {		send_message(0, ERROR, "Error: sin(0)\nExpected: 0.0000000000000000       Actual: %1.15f", result);		return (1);	    }	}	result = sin(pi / 2);	if (result != 1.0000000000000000) {	    if (result < (1.0000000000000000 - DPMARGIN) || 				result > (1.0000000000000000 + DPMARGIN)) {		send_message(0, ERROR, "Error: sin(pi/2)\nExpected: 1.0000000000000000       Actual: %1.15f", result);		return (1);	    }	}	result = sin(pi);	if (result != -(0.000000000410206)) {	    if (result < (-(0.000000000410206) - DPMARGIN) || 				result > (-(0.000000000410206) + DPMARGIN)) {		send_message(0, ERROR, "Error: sin(pi)\nExpected: -0.000000000410206       Actual: %1.15f", result);		return (1);	    }	}	result = sin((pi * 3) / 2);	if (result != -(1.0000000000000000)) {	    if (result < (-(1.0000000000000000) - DPMARGIN) || 				result > (-(1.0000000000000000) + DPMARGIN)) {		send_message(0, ERROR, "Error: sin(3pi/2)\nExpected: -1.0000000000000000 Actual: %1.15f", result);		return (1);	    }	}	result = sin(pi * 2);	if (result != 0.000000000820143) {	    if (result < (0.000000000820143 - DPMARGIN) || 				result > (0.00000000820143 + DPMARGIN)) {		send_message(0, ERROR, "Error: sin(2pi)\nExpected: 0.000000000820143 Actual: %1.15f", result);		return (1);	    }	}	/* cos of values in the range of -2pi to +2pi   */	result = cos(pi * (-2));	if (result != 1.0000000000000000) {	    if (result < (1.0000000000000000 - DPMARGIN) || 				result > (1.0000000000000000 + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(-2pi)\nExpected: 1.0000000000000000       Actual: %1.15f", result);		return (1);	    }	}	result = cos((pi * (-3)) / 2);	if (result != 0.000000000615310) {	    if (result < (0.000000000615310 - DPMARGIN) || 				result > (0.00000000615310 + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(-3pi/2)\nExpected: 0.000000000615310 Actual: %1.15f", result);		return (1);	    }	}	result = cos(-pi);	if (result != -(1.0000000000000000)) {	    if (result < (-(1.0000000000000000) - DPMARGIN) || 				result > (-(1.0000000000000000) + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(-pi)\nExpected: -1.0000000000000000 Actual: %1.15f", result);		return (1);	    }	}	result = cos(-(pi / 2));	if (result != -(0.000000000205103)) {	    if (result < (-(0.000000000205103) - DPMARGIN) || 				result > (-(0.000000000205103) + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(-pi/2)\nExpected: -0.000000000205103 Actual: %1.15f", result);		return (1);	    }	}	result = cos(0);	if (result != 1.0000000000000000) {	    if (result < (1.0000000000000000 - DPMARGIN) || 				result > (1.0000000000000000 + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(0)\nExpected: 1.0000000000000000       Actual: %1.15f", result);		return (1);	    }	}	result = cos(pi / 2);	if (result != (-0.000000000205103)) {	    if (result < (-(0.000000000205103) - DPMARGIN) || 				result > (-(0.000000000205103) + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(pi/2)\nExpected: -0.000000000205103 Actual: %1.15f", result);		return (1);	    }	}	result = cos(pi);	if (result != (-1.0000000000000000)) {	    if (result < (-(1.0000000000000000) - DPMARGIN) || 				result > (-(1.0000000000000000) + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(pi)\nExpected: -1.0000000000000000 Actual: %1.15f", result);		return (1);	    }	}	result = cos((pi * 3) / 2);	if (result != (0.000000000615310)) {	    if (result < (0.000000000615310 - DPMARGIN) || 				result > (0.00000000615310 + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(3pi/2)\nExpected: 0.000000000615310 Actual: %1.15f", result);		return (1);	    }	}	result = cos(pi * 2);	if (result != 1.0000000000000000) {	    if (result < (1.0000000000000000 - DPMARGIN) || 				result > (1.0000000000000000 + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(pi/2)\nExpected: 1.0000000000000000       Actual: %1.15f", result);		return (1);	    }	}	/* sin and cos of: pi/4, 3pi/4, 5pi/4 and 7pi/4  */	result = sin(pi / 4);	if (result != (0.707106781259062)) {	    if (result < (0.707106781259062 - DPMARGIN) || 				result > (0.707106781259062 + DPMARGIN)) {		send_message(0, ERROR, "Error: sin(pi/4)\nExpected: 0.707106781259062 Actual: %1.15f", result);		return (1);	    }	}	result = sin((pi * 3) / 4);	if (result != 0.707106780969002) {	    if (result < (0.707106780969002 - DPMARGIN) || 				result > (0.707106780969002 + DPMARGIN)) {		send_message(0, ERROR, "Error: sin(3pi/4)\nExpected: 0.707106780969002 Actual: %1.15f", result);		return (1);	    }	}	result = sin((pi * 5) / 4);	if (result != -(0.707106781549122)) {	    if (result < (-(0.707106781549122) - DPMARGIN) || 				result > (-(0.707106781549122) + DPMARGIN)) {		send_message(0, ERROR, "Error: sin(5pi/4)\nExpected: -0.707106781549122 Actual: %1.15f", result);		return (1);	    }	}	result = sin((pi * 7) / 4);	if (result != -(0.707106780678942)) {	    if (result < (-(0.707106780678942) - DPMARGIN) || 				result > (-(0.707106780678942) + DPMARGIN)) {		send_message(0, ERROR, "Error: sin(7pi/4)\nExpected: -0.707106780678942 Actual: %1.15f", result);		return (1);	    }	}	result = cos(pi / 4);	if (result != 0.707106781114032) {	    if (result < (0.707106781114032 - DPMARGIN) || 				result > (0.707106781114032 + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(pi/4)\n Expected: 0.707106781114032 Actual: %1.15f", result);		return (1);	    }	}	result = cos((pi * 3) / 4);	if (result != -(0.707106781404092)) {	    if (result < (-(0.707106781404092) - DPMARGIN) || 				result > (-(0.707106781404092) + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(3pi/4)\n Expected: -0.707106781404092 Actual: %1.15f", result);		return (1);	    }	}	result = cos((pi * 5) / 4);	if (result != -(0.707106780823972)) {	    if (result < (-(0.707106780823972) - DPMARGIN) || 				result > (-(0.707106780823972) + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(5pi/4)\n Expected: -0.707106780823972 Actual: %1.15f", result);		return (1);	    }	}	result = cos((pi * 7) / 4);	if (result != (0.707106781694152)) {	    if (result < (0.707106781694152 - DPMARGIN) || 				result > (0.707106781694152 + DPMARGIN)) {		send_message(0, ERROR, "Error: cos(7pi/4)\n Expected: 0.707106781694152 Actual: %1.15f", result);		return (1);	    }	}	/* exponential		 */	x = exp(0.0);	if (x != 1.0000000000000000) {	    if (x < (1.0000000000000000 - DPMARGIN) || 				x > (1.0000000000000000 + DPMARGIN)) {		send_message(0, ERROR, "Error: exp(0)\n Expected: 1.0000000000000000 Actual: %1.15f", x);		return (1);	    }	}	x = exp(1.0);	if (x != 2.718281828459045) {	    if (x < (2.718281828459045 - DPMARGIN) || 				x > (2.718281828459045 + DPMARGIN)) {		send_message(0, ERROR, "Error: exp(1)\n Expected: 2.718281828459045 Actual: %1.15f", x);		return (1);	    }	}	x = exp(2.0);	if (x != 7.389056098930650) {	    if (x < (7.389056098930650 - DPMARGIN) || 				x > (7.389056098930650 + DPMARGIN)) {		send_message(0, ERROR, "Error: exp(2)\n Expected: 7.389056098930650 Actual: %1.15f", x);		return (1);	    }	}	x = exp(5.0);	if (x != 148.413159102576600) {	    if (x < (148.413159102576600 - DPMARGIN) || 				x > (148.413159102576600 + DPMARGIN)) {		send_message(0, ERROR, "Error: exp(5)\n Expected: 148.413159102576600 Actual: %1.15f", x);		return (1);	    }	}	x = exp(10.0);	if (x != 22026.465794806718000) {	    if (x < (22026.465794806718000 - DPMARGIN) || 				x > (22026.465794806718000 + DPMARGIN)) {		send_message(0, ERROR, "Error: exp(10)\n Expected: 22026.465794806718000 Actual: %1.15f", x);		return (1);	    }	}	x = exp(-1.0);	if (x != 0.367879441171442) {	    if (x < (0.367879441171442 - DPMARGIN) || 				x > (0.367879441171442 + DPMARGIN)) {		send_message(0, ERROR, "Error: exp(-1)\n Expected: 0.367879441171442 Actual: %1.15f", x);		return (1);	    }	}	x = exp(-2.0);	if (x != 0.135335283236612) {	    if (x < (0.135335283236612 - DPMARGIN) || 				x > (0.135335283236612 + DPMARGIN)) {		send_message(0, ERROR, "Error: exp(-2)\nExpected: 0.135335283236612 Actual: %1.15f", x);		return (1);	    }	}	x = exp(-5.0);	if (x != 0.006737946999085) {	    if (x < (0.006737946999085 - DPMARGIN) || 				x > (0.006737946999085 + DPMARGIN)) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -