]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
softfloat: define floatx80_round()
authorLaurent Vivier <laurent@vivier.eu>
Wed, 28 Jun 2017 20:42:38 +0000 (22:42 +0200)
committerLaurent Vivier <laurent@vivier.eu>
Thu, 29 Jun 2017 18:27:39 +0000 (20:27 +0200)
Add a function to round a floatx80 to the defined precision
(floatx80_rounding_precision)

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Message-Id: <20170628204241.32106-5-laurent@vivier.eu>

fpu/softfloat.c
include/fpu/softfloat.h

index 7af14e29aad57c056ddbe84c4b0d21568faeca01..433c5dad2d48cf42924682ead46ca95d0e8edd2d 100644 (file)
@@ -5085,6 +5085,22 @@ float128 floatx80_to_float128(floatx80 a, float_status *status)
 
 }
 
+/*----------------------------------------------------------------------------
+| Rounds the extended double-precision floating-point value `a'
+| to the precision provided by floatx80_rounding_precision and returns the
+| result as an extended double-precision floating-point value.
+| The operation is performed according to the IEC/IEEE Standard for Binary
+| Floating-Point Arithmetic.
+*----------------------------------------------------------------------------*/
+
+floatx80 floatx80_round(floatx80 a, float_status *status)
+{
+    return roundAndPackFloatx80(status->floatx80_rounding_precision,
+                                extractFloatx80Sign(a),
+                                extractFloatx80Exp(a),
+                                extractFloatx80Frac(a), 0, status);
+}
+
 /*----------------------------------------------------------------------------
 | Rounds the extended double-precision floating-point value `a' to an integer,
 | and returns the result as an extended quadruple-precision floating-point
index f1288efa87b6805cb3c3f40b23c9115bc6279cd7..d9689eca2a3be033ebc854a3a36847d9c53e4b9d 100644 (file)
@@ -621,6 +621,7 @@ float128 floatx80_to_float128(floatx80, float_status *status);
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE extended double-precision operations.
 *----------------------------------------------------------------------------*/
+floatx80 floatx80_round(floatx80 a, float_status *status);
 floatx80 floatx80_round_to_int(floatx80, float_status *status);
 floatx80 floatx80_add(floatx80, floatx80, float_status *status);
 floatx80 floatx80_sub(floatx80, floatx80, float_status *status);