modf.c

来自「minix操作系统最新版本(3.1.1)的源代码」· C语言 代码 · 共 62 行

C
62
字号
/*libc/ieee_float/modf.cCreated:	Oct 14, 1993 by Philip Homburg <philip@cs.vu.nl>Implementation of modf that directly manipulates the exponent bits in anieee float*/#include <sys/types.h>#include <math.h>#include "ieee_float.h"double modf(value, iptr)double value;double *iptr;{	struct f64 *f64p;	double tmp;	int exp;	int mask_bits;	u32_t mant;	f64p= (struct f64 *)&value;	exp= F64_GET_EXP(f64p);	exp -= F64_EXP_BIAS;	if (exp < 0)	{		*iptr= 0;		return value;	}	mask_bits= 52-exp;	if (mask_bits <= 0)	{		*iptr= value;		return 0;	}	tmp= value;	if (mask_bits >= 32)	{		F64_SET_MANT_LOW(f64p, 0);		mask_bits -= 32;		mant= F64_GET_MANT_HIGH(f64p);		mant &= ~((1 << mask_bits)-1);		F64_SET_MANT_HIGH(f64p, mant);	}	else	{		mant= F64_GET_MANT_LOW(f64p);		mant &= ~((1 << mask_bits)-1);		F64_SET_MANT_LOW(f64p, mant);	}	*iptr= value;	return tmp-value;}/* * $PchId: modf.c,v 1.3 1996/02/22 21:01:39 philip Exp $ */

⌨️ 快捷键说明

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