[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v1 16/19] fpu/softfloat: re-factor int/uint to f
From: |
Alex Bennée |
Subject: |
Re: [Qemu-devel] [PATCH v1 16/19] fpu/softfloat: re-factor int/uint to float |
Date: |
Tue, 12 Dec 2017 17:21:45 +0000 |
User-agent: |
mu4e 1.0-alpha2; emacs 26.0.90 |
Alex Bennée <address@hidden> writes:
> These are considerably simpler as the lower order integers can just
> use the higher order conversion function. As the decomposed fractional
> part is a full 64 bit rounding and inexact handling comes from the
> pack functions.
<snip>
>
> +/*
> + * Integer to float conversions
> + *
> + * Returns the result of converting the two's complement integer `a'
> + * to the floating-point format. The conversion is performed according
> + * to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
> + */
> +
> +static decomposed_parts int_to_float(int64_t a, float_status *status)
> +{
> + decomposed_parts r;
> + if (a == 0) {
> + r.cls = float_class_zero;
> + } else if (a == (1ULL << 63)) {
As the re-pack code can handle -0 we need to explicitly set it here as
we are building decomposed_parts from scratch:
if (a == 0) {
r.cls = float_class_zero;
r.sign = false;
} else if (a == (1ULL << 63)) {
And also at:
> +
> +/*
> + * Unsigned Integer to float conversions
> + *
> + * Returns the result of converting the unsigned integer `a' to the
> + * floating-point format. The conversion is performed according to the
> + * IEC/IEEE Standard for Binary Floating-Point Arithmetic.
> + */
> +
> +static decomposed_parts uint_to_float(uint64_t a, float_status *status)
> +{
> + decomposed_parts r;
> + if (a == 0) {
> + r.cls = float_class_zero;
> + } else {
Now reads:
decomposed_parts r = { .sign = false};
if (a == 0) {
r.cls = float_class_zero;
} else {
int spare_bits = clz64(a) - 1;
r.cls = float_class_normal;
--
Alex Bennée
- Re: [Qemu-devel] [PATCH v1 17/19] fpu/softfloat: re-factor scalbn, (continued)
- [Qemu-devel] [PATCH v1 10/19] fpu/softfloat: re-factor add/sub, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 13/19] fpu/softfloat: re-factor muladd, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 15/19] fpu/softfloat: re-factor float to int/uint, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 11/19] fpu/softfloat: re-factor mul, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 16/19] fpu/softfloat: re-factor int/uint to float, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 18/19] fpu/softfloat: re-factor minmax, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 12/19] fpu/softfloat: re-factor div, Alex Bennée, 2017/12/11
- Re: [Qemu-devel] [PATCH v1 00/19] re-factor softfloat and add fp16 functions, no-reply, 2017/12/14