opt11.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 31 行
C
31 行
#include "fail.h"
#include <math.h>
#include <stdio.h>
#include <new.h>
double *Magnitude( double *Length, double *v, int n )
{
register int t;
if(n<1) return 0;
*Length=0.0;
for(t=0; t<n; t++)
*Length+=v[t]*v[t];
Length = new (Length) double; // try to force into EAX
*Length=sqrt(*Length);
return Length;
}
main()
{
double x[2] = { 1.0, 2.0 };
double mag;
int n=2;
Magnitude(&mag,x,n);
// sqrt(5) ~= 2.23
if( mag < 2.2 || mag > 2.3 ) fail(__LINE__);
_PASS;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?