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

📄 cmul32.cpp

📁 这是我本人编写的一个32位定点小数运算的函数库。对于没有浮点运算器的场合
💻 CPP
字号:
//
//
//

#include "stdafx.h"

extern "C" {

////////////////////////////////////////////////////////////

long dosFIX_MPY32_C(long x,long y)
{
	short x1=*((short*)(&x)+1),y1=*((short*)(&y)+1);
	unsigned short x0=*((unsigned short*)(&x)),y0=*((unsigned short*)(&y));

	long z1=(long)x1*(long)y1;
	long z21=(long)x1*(long)y0;
	long z22=(long)x0*y1;
	long z3=(long)x0*(long)y0;
	long z=z1+*((short*)(&z21)+1)+*((short*)(&z22)+1);
	long z0=*((unsigned short*)(&z3)+1)+*(unsigned short*)(&z21)+*(unsigned short*)(&z22);

	return (z<<1)+(z0>>15)+((z0&(1<<14))?1:0);
}

////////////////////////////////////////////////////////////

};

⌨️ 快捷键说明

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