_ftou.c
来自「操作系统SunOS 4.1.3版本的源码」· C语言 代码 · 共 52 行
C
52 行
#ifndef lintstatic char sccsid[] = "@(#)_ftou.c 1.1 92/07/30 SMI";#endif/* * Copyright (c) 1987 by Sun Microsystems, Inc. */unsigned _dtou(d) double d;{ /* Convert double to unsigned. */ int id; /* * id = d is correct if 0 <= d < 2**31, and good enough if d is NaN * or d < 0 or d >= 2**32. Otherwise, since the result (int) d of * converting 2**31 <= d < 2**32 is unknown, adjust d before the * conversion. */ if (d >= 2147483648.0) id = 0x80000000 | (int) (d - 2147483648.0); else id = (int) d; return (unsigned) id;}unsigned _ftou(dd) int dd; /* really float */{ /* Convert float to unsigned. */ int id; double d = (double) *((float *)(&dd)); /* * id = d is correct if 0 <= d < 2**31, and good enough if d is NaN * or d < 0 or d >= 2**32. Otherwise, since the result (int) d of * converting 2**31 <= d < 2**32 is unknown, adjust d before the * conversion. */ if (d >= 2147483648.0) id = 0x80000000 | (int) (d - 2147483648.0); else id = (int) d; return (unsigned) id;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?