logtable.cpp
来自「这是我本人编写的一个32位定点小数运算的函数库。对于没有浮点运算器的场合」· C++ 代码 · 共 32 行
CPP
32 行
// LogTable.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define MAXLOG 32
#define TABLESIZE 46
#define LOGONE (0x80000000u/MAXLOG)
const int ListLen=1024;
main()
{
for (int i=0;i<ListLen;i++) {
double x=1.0+(double)i/(double)ListLen,y=log(x);
long u=(long)(y*LOGONE+0.5);
printf("%ld, ",u);
if (i%7==6) printf("\n");
}
printf("\n"); printf("\n");
for (i=-TABLESIZE;i<=TABLESIZE;i++) {
double x=log(2)*i;
long u=(long)(x*LOGONE+0.5);
printf("%ld, ",u);
if ((i+TABLESIZE)%6==5) printf("\n");
}
getch(); return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?