aboutsummaryrefslogtreecommitdiff
path: root/softfloat/s_roundPackToF64.c
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@s141.Millennium.Berkeley.EDU>2011-06-19 21:45:58 -0700
committerAndrew Waterman <waterman@s141.Millennium.Berkeley.EDU>2011-06-19 21:45:58 -0700
commit1e163c715550e20e239976a22e00869884713e54 (patch)
treedbcf7b10e35421c72758df098057014fef7ffff7 /softfloat/s_roundPackToF64.c
parent0edaecc54329048eb91ad6a45338265ef1a4569c (diff)
downloadpk-1e163c715550e20e239976a22e00869884713e54.zip
pk-1e163c715550e20e239976a22e00869884713e54.tar.gz
pk-1e163c715550e20e239976a22e00869884713e54.tar.bz2
fixed build after repo split
Diffstat (limited to 'softfloat/s_roundPackToF64.c')
-rwxr-xr-xsoftfloat/s_roundPackToF64.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/softfloat/s_roundPackToF64.c b/softfloat/s_roundPackToF64.c
new file mode 100755
index 0000000..fb0ef1d
--- /dev/null
+++ b/softfloat/s_roundPackToF64.c
@@ -0,0 +1,66 @@
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "primitives.h"
+#include "internals.h"
+#include "softfloat.h"
+
+float64_t
+ softfloat_roundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
+{
+ int roundingMode;
+ bool roundNearestEven;
+ int roundIncrement, roundBits;
+ bool isTiny;
+ uint_fast64_t uiZ;
+ union ui64_f64 uZ;
+
+ roundingMode = softfloat_roundingMode;
+ roundNearestEven = ( roundingMode == softfloat_round_nearest_even );
+ roundIncrement = 0x200;
+ if (
+ ! roundNearestEven
+ && ( roundingMode != softfloat_round_nearest_maxMag )
+ ) {
+ roundIncrement =
+ ( roundingMode == softfloat_round_minMag )
+ || ( roundingMode
+ == ( sign ? softfloat_round_max : softfloat_round_min ) )
+ ? 0
+ : 0x3FF;
+ }
+ roundBits = sig & 0x3FF;
+ if ( 0x7FD <= (uint16_t) exp ) {
+ if ( exp < 0 ) {
+ isTiny =
+ ( softfloat_detectTininess
+ == softfloat_tininess_beforeRounding )
+ || ( exp < -1 )
+ || ( sig + roundIncrement < UINT64_C( 0x8000000000000000 ) );
+ sig = softfloat_shift64RightJam( sig, - exp );
+ exp = 0;
+ roundBits = sig & 0x3FF;
+ if ( isTiny && roundBits ) {
+ softfloat_raiseFlags( softfloat_flag_underflow );
+ }
+ } else if (
+ ( 0x7FD < exp )
+ || ( UINT64_C( 0x8000000000000000 ) <= sig + roundIncrement )
+ ) {
+ softfloat_raiseFlags(
+ softfloat_flag_overflow | softfloat_flag_inexact );
+ uiZ = packToF64UI( sign, 0x7FF, 0 ) - ! roundIncrement;
+ goto uiZ;
+ }
+ }
+ if ( roundBits ) softfloat_exceptionFlags |= softfloat_flag_inexact;
+ sig = ( sig + roundIncrement )>>10;
+ sig &= ~ ( ! ( roundBits ^ 0x200 ) & roundNearestEven );
+ uiZ = packToF64UI( sign, sig ? exp : 0, sig );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+