softfloat-specialize.h
来自「基于组件方式开发操作系统的OSKIT源代码」· C头文件 代码 · 共 174 行
H
174 行
/* $NetBSD: softfloat-specialize.h,v 1.3 1998/01/06 00:06:12 perry Exp $ *//*===============================================================================This C source fragment is part of the SoftFloat IEC/IEEE Floating-pointArithmetic Package, Release 1a.Written by John R. Hauser. This work was made possible by the InternationalComputer Science Institute, located at Suite 600, 1947 Center Street,Berkeley, California 94704. Funding was provided in part by the NationalScience Foundation under grant MIP-9311980. The original version ofthis code was written as part of a project to build a fixed-point vectorprocessor in collaboration with the University of California at Berkeley,overseen by Profs. Nelson Morgan and John Wawrzynek. More informationis available through the web page `http://www.cs.berkeley.edu/~jhauser/softfloat.html'.THIS PACKAGE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort hasbeen made to avoid it, THIS PACKAGE MAY CONTAIN FAULTS THAT WILL AT TIMESRESULT IN INCORRECT BEHAVIOR. USE OF THIS PACKAGE IS RESTRICTED TO PERSONSAND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY AND ALLLOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.Derivative works are acceptable, even for commercial purposes, so long as(1) they include prominent notice that the work is derivative, and (2) theyinclude prominent notice akin to these three paragraphs for those parts ofthis code that are retained.===============================================================================*/flag float32_is_signaling_nan( float32 a );flag float64_is_signaling_nan( float64 a );/*-------------------------------------------------------------------------------Underflow tininess-detection mode. (Statically initialized to default.)-------------------------------------------------------------------------------*/flag float_detect_tininess = float_tininess_after_rounding;/*-------------------------------------------------------------------------------Raises the exceptions specified by `flags'. Floating-point traps can bedefined here if desired. It is currently not possible for such a trap tosubstitute a result value. If traps are not implemented, this routineshould be simply `float_exception_flags |= flags;'.-------------------------------------------------------------------------------*/void float_raise( uint8 flags ){ float_exception_flags |= flags;}/*-------------------------------------------------------------------------------The pattern for a default generated single-precision NaN.-------------------------------------------------------------------------------*/enum { float32_default_nan = 0xFFC00000};/*-------------------------------------------------------------------------------The pattern for a default generated double-precision NaN. The `high' and`low' words hold the most- and least-significant bits, respectively.-------------------------------------------------------------------------------*/enum { float64_default_nan_high = 0xFFF80000, float64_default_nan_low = 0x00000000};/*-------------------------------------------------------------------------------Returns true if the single-precision floating-point value `a' is a signalingNaN; otherwise returns false.-------------------------------------------------------------------------------*/flag float32_is_signaling_nan( float32 a ){ return ( ( a & 0x7FC00000 ) == 0x7F800000 ) && ( a & 0x003FFFFF );}/*-------------------------------------------------------------------------------Returns true if the double-precision floating-point value `a' is a signalingNaN; otherwise returns false.-------------------------------------------------------------------------------*/flag float64_is_signaling_nan( float64 a ){ return ( ( a.high & 0x7FF80000 ) == 0x7FF00000 ) && ( ( a.high & 0x0007FFFF ) || a.low );}/*-------------------------------------------------------------------------------Converts a single-precision NaN `a' to a double-precision quiet NaN. If `a'is a signaling NaN, the invalid exception is raised.-------------------------------------------------------------------------------*/static float64 float32ToFloat64NaN( float32 a ){ float64 z; if ( float32_is_signaling_nan( a ) ) float_raise( float_flag_invalid ); z.low = float64_default_nan_low; z.high = float64_default_nan_high; return z;}/*-------------------------------------------------------------------------------Converts a double-precision NaN `a' to a single-precision quiet NaN. If `a'is a signaling NaN, the invalid exception is raised.-------------------------------------------------------------------------------*/static float32 float64ToFloat32NaN( float64 a ){ if ( float64_is_signaling_nan( a ) ) float_raise( float_flag_invalid ); return float32_default_nan;}/*-------------------------------------------------------------------------------Takes two single-precision floating-point values `a' and `b', one of whichis a NaN, and returns the appropriate NaN result. If either `a' or `b' is asignaling NaN, the invalid exception is raised.-------------------------------------------------------------------------------*/static float32 propagateFloat32NaN( float32 a, float32 b ){ if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) { float_raise( float_flag_invalid ); } return float32_default_nan;}/*-------------------------------------------------------------------------------Takes two double-precision floating-point values `a' and `b', one of whichis a NaN, and returns the appropriate NaN result. If either `a' or `b' is asignaling NaN, the invalid exception is raised.-------------------------------------------------------------------------------*/static float64 propagateFloat64NaN( float64 a, float64 b ){ float64 z; if ( float64_is_signaling_nan( a ) || float64_is_signaling_nan( b ) ) { float_raise( float_flag_invalid ); } z.low = float64_default_nan_low; z.high = float64_default_nan_high; return z;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?