NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-mips/57680: printf("%.1f") shows wrong resultsonR3000mipseb



The following reply was made to PR port-mips/57680; it has been noted by GNATS.

From: Izumi Tsutsui <tsutsui%ceres.dti.ne.jp@localhost>
To: riastradh%NetBSD.org@localhost
Cc: gnats-bugs%netbsd.org@localhost, tsutsui%ceres.dti.ne.jp@localhost
Subject: Re: port-mips/57680: printf("%.1f") shows wrong resultsonR3000mipseb
Date: Sun, 5 Nov 2023 14:04:41 +0900

 riastradh@ wrote:
 
 > Perhaps on these CPUs, the kernel is setting the default rounding mode
 > wrong when it enters a new userland process.  You could test this by
 > writing a program that just queries fegetround and prints the value:
 > 
 > #include <fenv.h>
 > #include <stdio.h>
 > 
 > int
 > main(void)
 > {
 > 	printf("FE_TONEAREST = %d\n", (int)FE_TONEAREST);
 > 	printf("fegetround() = %d\n", (int)fegetround());
 > 	fflush(stdout);
 > 	return ferror(stdout);
 > }
 
 This shows:
 ---
 news3470-% uname -a
 NetBSD galant 9.3 NetBSD 9.3 (GENERIC) #0: Sat Nov  4 23:42:11 JST 2023  tsutsui@mirage:/s/tsutsui/netbsd-src/sys/arch/newsmips/compile/obj.newsmips/GENERIC newsmips
 news3470-% cat fetest.c 
 #include <fenv.h>
 #include <stdio.h>
 
 int
 main(void)
 {
         printf("FE_TONEAREST = %d\n", (int)FE_TONEAREST);
         printf("fegetround() = %d\n", (int)fegetround());
         fflush(stdout);
         return ferror(stdout);
 }
 
 news3470-% cc -o fetest fetest.c
 news3470-% ./fetest
 FE_TONEAREST = 0
 fegetround() = 0
 news3470-% 
 ---
 
 So the default round mode (at least in C) seems correct.
 
 ---
 Izumi Tsutsui
 


Home | Main Index | Thread Index | Old Index