sqrttab.cpp

来自「这是我本人编写的一个32位定点小数运算的函数库。对于没有浮点运算器的场合」· C++ 代码 · 共 24 行

CPP
24
字号
// SqrtTab.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

int main()
{
	FILE *f=fopen("sqtab.txt","wt");
	for (int i=0;i<1024*3;i++) {
		int n=i+1024;
		double x=sqrt((double)n/(1024*4));
		int ix=(int)(x*(double)(1<<16)*(double)(1<<16)+0.5);
		printf("%u, ",ix); fprintf(f,"%u, ",ix);
		if (i%6==5) {
			printf("\n"); fprintf(f,"\n");
		}
	}
	fclose(f); getch(); return 0;
}

⌨️ 快捷键说明

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