On 2017/6/12 23:24, Martell Malone wrote:
In this thread https://sourceforge.net/p/mingw-w64/bugs/459/
there is a suggested fix for print with whole numbers
The builtin __mingw_printf is inconsistent with printf on %a format.
I think __mingw_printf is wrong, because obviously 1.0 != 0x0p-63.
vacaboja opened an issue on msys2 for this
https://github.com/msys2/msys2/issues/35
and suggested a fix of removing the case to int
here is a patch that does just that.
Please Review
The patch does fix the bug, imperfectly nevertheless...
With this patch applied now the result is as follows:
```
E:\Desktop>expand -t4 test.c
#include <stdio.h>
int main(){
__builtin_printf("%a %a\n", 1.0, 1.1);
__mingw_printf("%a %a\n", 1.0, 1.1);
}
E:\Desktop>gcc test.c -L.
E:\Desktop>a.exe
0x1.000000p+0 0x1.19999ap+0
0x8p-3 0x8.cccccccccccdp-3
```
`0x8p-3 = 8 * 2^-3 = 8 * 1 / 8 = 1` hence the result is correct.
But it still does not agree with `printf` from MSVCRT.
--
Best regards,
LH_Mouse
From ff27b6d4d605b8296f814855f183e790b65183d3 Mon Sep 17 00:00:00 2001
From: Liu Hao <[email protected]>
Date: Thu, 15 Jun 2017 11:43:15 +0800
Subject: [PATCH] mingw-w64-crt/stdio/mingw_pformat.c: Perform 64-bit
comparison on the mantissa of a floating point number. This fixes #459.
Reference: https://sourceforge.net/p/mingw-w64/bugs/459/
Signed-off-by: Liu Hao <[email protected]>
---
mingw-w64-crt/stdio/mingw_pformat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mingw-w64-crt/stdio/mingw_pformat.c
b/mingw-w64-crt/stdio/mingw_pformat.c
index 445320c0..350c6638 100644
--- a/mingw-w64-crt/stdio/mingw_pformat.c
+++ b/mingw-w64-crt/stdio/mingw_pformat.c
@@ -2112,8 +2112,8 @@ void __pformat_emit_xfloat( __pformat_fpreg_t value,
__pformat_t *stream )
{
/* taking the rightmost digit in each pass...
*/
- int c = value.__pformat_fpreg_mantissa & 0xF;
- if( c == (int) value.__pformat_fpreg_mantissa)
+ unsigned c = value.__pformat_fpreg_mantissa & 0xF;
+ if( c == value.__pformat_fpreg_mantissa)
{
/* inserting the radix point, when we reach the last,
* (i.e. the most significant digit), unless we found no
--
2.13.0
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public