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

📄 sqrt.c

📁 上一个上传的有问题,这个是好的。visopsys包括系统内核和GUI的全部SOURCE code ,还包括一些基本的docs文档。里面src子目录对应所有SOURCE code.对于想研究操作系统的朋
💻 C
字号:
// //  This is the standard "sqrt" function, as found in standard C libraries.////  Copyright (C) Paul Hsieh, 1996-2004.////  Paul's square root page is here://    http://www.azillionmonkeys.com/qed/sqroot.html////  sqrt.c//#include <math.h>#define itable ((double *) xtable)static int xtable[16] = {  0x540bcb0d, 0x3fe56936, 0x415a86d3, 0x3fe35800, 0xd9ac3519, 0x3fe1c80d,  0x34f91569, 0x3fe08be9, 0x8f3386d8, 0x3fee4794, 0x9ea02719, 0x3feb5b28,  0xe4ff9edc, 0x3fe92589, 0x1c52539d, 0x3fe76672};static int norm2(double *t){  unsigned e, f, g;    f = ((((unsigned *) t)[1]) >> 1);  e = ((unsigned *) t)[1];  f += 0x1FF80000;  g = (e & 0x000FFFFF);  f &= 0xFFF00000;  ((int *) t)[1] =  g + 0x40000000 - (e & 0x00100000);    return (f);}double sqrt(double y){  double a;  int e, c;  e = norm2(&y);  c = (((int *) &y)[1]) >> (18) & (7);  a = itable[c];    for(c = 0; c < 6; c++)    a = 0.5 * a * (3.0 - y * a * a);  a *= y;    ((int *) &a)[1] &= 0x000FFFFF;  ((int *) &a)[1] |= e;    return (a);}

⌨️ 快捷键说明

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