[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-stable] [PATCH 1/1] Fix conversion from uint64 to float128
From: |
Petr Tesarik |
Subject: |
Re: [Qemu-stable] [PATCH 1/1] Fix conversion from uint64 to float128 |
Date: |
Fri, 11 May 2018 09:38:03 +0200 |
On Fri, 11 May 2018 09:10:52 +0200
Petr Tesarik <address@hidden> wrote:
> The significand is passed to normalizeRoundAndPackFloat128() as high
> first, low second. The current code passes the integer first, so the
> result is incorrectly shifted left by 64 bits.
>
> This bug affects the emulation of s390x instruction CXLGBR (convert
> from logical 64-bit binary-integer operand to extended BFP result).
I forgot to add a simple reproducer:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
unsigned long long x = atoll(argv[1]);
long double d = x;
printf("%llu -> %Lf\n", x, d);
return 0;
}
On a real s390x, I get this:
linux-nig1:~ # ./cast 1
1 -> 1.000000
An s390x emulated with (unpatched) qemu-system-s390x gives:
linux-2s2c:~ # ./cast 1
1 -> 18446744073709551616.000000
That is 2^64.
Petr T