softfloat.txt
来自「基于4个mips核的noc设计」· 文本 代码 · 共 375 行 · 第 1/2 页
TXT
375 行
spurious underflow signals. The other option is provided for compatibilitywith some systems. Like most systems, SoftFloat always detects loss ofaccuracy for underflow as an inexact result.----------------------------------------------------------------------------Function Details- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Conversion FunctionsAll conversions among the floating-point formats are supported, as are allconversions between a floating-point format and 32-bit and 64-bit signedintegers. The complete set of conversion functions is: int32_to_float32 int64_to_float32 int32_to_float64 int64_to_float32 int32_to_floatx80 int64_to_floatx80 int32_to_float128 int64_to_float128 float32_to_int32 float32_to_int64 float32_to_int32 float64_to_int64 floatx80_to_int32 floatx80_to_int64 float128_to_int32 float128_to_int64 float32_to_float64 float32_to_floatx80 float32_to_float128 float64_to_float32 float64_to_floatx80 float64_to_float128 floatx80_to_float32 floatx80_to_float64 floatx80_to_float128 float128_to_float32 float128_to_float64 float128_to_floatx80Each conversion function takes one operand of the appropriate type andreturns one result. Conversions from a smaller to a larger floating-pointformat are always exact and so require no rounding. Conversions from 32-bitintegers to double precision and larger formats are also exact, and likewisefor conversions from 64-bit integers to extended double and quadrupleprecisions.Conversions from floating-point to integer raise the invalid exception ifthe source value cannot be rounded to a representable integer of the desiredsize (32 or 64 bits). If the floating-point operand is a NaN, the largestpositive integer is returned. Otherwise, if the conversion overflows, thelargest integer with the same sign as the operand is returned.On conversions to integer, if the floating-point operand is not alreadyan integer value, the operand is rounded according to the current roundingmode as specified by `float_rounding_mode'. Because C (and perhaps otherlanguages) require that conversions to integers be rounded toward zero, thefollowing functions are provided for improved speed and convenience: float32_to_int32_round_to_zero float32_to_int64_round_to_zero float64_to_int32_round_to_zero float64_to_int64_round_to_zero floatx80_to_int32_round_to_zero floatx80_to_int64_round_to_zero float128_to_int32_round_to_zero float128_to_int64_round_to_zeroThese variant functions ignore `float_rounding_mode' and always round towardzero.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Standard Arithmetic FunctionsThe following standard arithmetic functions are provided: float32_add float32_sub float32_mul float32_div float32_sqrt float64_add float64_sub float64_mul float64_div float64_sqrt floatx80_add floatx80_sub floatx80_mul floatx80_div floatx80_sqrt float128_add float128_sub float128_mul float128_div float128_sqrtEach function takes two operands, except for `sqrt' which takes only one.The operands and result are all of the same type.Rounding of the extended double-precision (`floatx80') functions is affectedby the `floatx80_rounding_precision' variable, as explained above in thesection _Extended Double-Precision Rounding Precision_.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Remainder FunctionsFor each format, SoftFloat implements the remainder function according tothe IEC/IEEE Standard. The remainder functions are: float32_rem float64_rem floatx80_rem float128_remEach remainder function takes two operands. The operands and result are allof the same type. Given operands x and y, the remainder functions returnthe value x - n*y, where n is the integer closest to x/y. If x/y is exactlyhalfway between two integers, n is the even integer closest to x/y. Theremainder functions are always exact and so require no rounding.Depending on the relative magnitudes of the operands, the remainderfunctions can take considerably longer to execute than the other SoftFloatfunctions. This is inherent in the remainder operation itself and is not aflaw in the SoftFloat implementation.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Round-to-Integer FunctionsFor each format, SoftFloat implements the round-to-integer functionspecified by the IEC/IEEE Standard. The functions are: float32_round_to_int float64_round_to_int floatx80_round_to_int float128_round_to_intEach function takes a single floating-point operand and returns a result ofthe same type. (Note that the result is not an integer type.) The operandis rounded to an exact integer according to the current rounding mode, andthe resulting integer value is returned in the same floating-point format.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Comparison FunctionsThe following floating-point comparison functions are provided: float32_eq float32_le float32_lt float64_eq float64_le float64_lt floatx80_eq floatx80_le floatx80_lt float128_eq float128_le float128_ltEach function takes two operands of the same type and returns a 1 or 0representing either _true_ or _false_. The abbreviation `eq' stands for``equal'' (=); `le' stands for ``less than or equal'' (<=); and `lt' standsfor ``less than'' (<).The standard greater-than (>), greater-than-or-equal (>=), and not-equal(!=) functions are easily obtained using the functions provided. Thenot-equal function is just the logical complement of the equal function.The greater-than-or-equal function is identical to the less-than-or-equalfunction with the operands reversed, and the greater-than function isidentical to the less-than function with the operands reversed.The IEC/IEEE Standard specifies that the less-than-or-equal and less-thanfunctions raise the invalid exception if either input is any kind of NaN.The equal functions, on the other hand, are defined not to raise the invalidexception on quiet NaNs. For completeness, SoftFloat provides the followingadditional functions: float32_eq_signaling float32_le_quiet float32_lt_quiet float64_eq_signaling float64_le_quiet float64_lt_quiet floatx80_eq_signaling floatx80_le_quiet floatx80_lt_quiet float128_eq_signaling float128_le_quiet float128_lt_quietThe `signaling' equal functions are identical to the standard functionsexcept that the invalid exception is raised for any NaN input. Likewise,the `quiet' comparison functions are identical to their counterparts exceptthat the invalid exception is not raised for quiet NaNs.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Signaling NaN Test FunctionsThe following functions test whether a floating-point value is a signalingNaN: float32_is_signaling_nan float64_is_signaling_nan floatx80_is_signaling_nan float128_is_signaling_nanThe functions take one operand and return 1 if the operand is a signalingNaN and 0 otherwise.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Raise-Exception FunctionSoftFloat provides a function for raising floating-point exceptions: float_raiseThe function takes a mask indicating the set of exceptions to raise. Noresult is returned. In addition to setting the specified exception flags,this function may cause a trap or abort appropriate for the current system.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -----------------------------------------------------------------------------Contact InformationAt the time of this writing, the most up-to-date information aboutSoftFloat and the latest release can be found at the Web page `http://www.cs.berkeley.edu/~jhauser/arithmetic/SoftFloat.html'.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?