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 results on R3000 mipseb



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: gnats-bugs%netbsd.org@localhost
Cc: tsutsui%ceres.dti.ne.jp@localhost
Subject: Re: port-mips/57680: printf("%.1f") shows wrong results on R3000 mipseb
Date: Fri, 3 Nov 2023 14:37:55 +0900

 > >Description:
 > On NetBSD/newsmips 9.3 on NWS-3470 (maybe also other R3000 machines)
 > printf with "%.1f" shows wrong results.
 > 
 > >How-To-Repeat:
  :
 > news3470-% cat test.c
 > #include <stdio.h>
 > 
 > int
 > main(int argc, char *argv[])
 > {
 >         float f;
 > 
 >         f = 3.14159 * 100;
 >         printf("%.1f\n", f);
 >         printf("%d\n", (int)f);
 > 
 >         f = f * 5;
 >         printf("%.1f\n", f);
 >         printf("%d\n", (int)f);
 > }
 > news3470-% cc test.c
 > news3470-% ./a.out
 > 300.0
 > 314
 > ?00.0
 > 1570
 > news3470-% 
 
 The news3470 has R3000 and R3010 FPU:
 ---
 news3470-% grep ^cpu0 /var/run/dmesg.boot 
 cpu0 at mainbus0: MIPS R3000 CPU (0x220) Rev. 2.0 with MIPS R3010 FPC Rev. 2.0
 cpu0: 64KB/4B direct-mapped Instruction cache, 64 TLB entries
 cpu0: 64KB/4B direct-mapped write-through Data cache
 ---
 
 I've also tested on R4400 NWS-5000 and it works without problem:
 ---
 news5000-% uname -a
 NetBSD vrfour 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug  4 15:30:37 UTC 2022  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/newsmips/compile/GENERIC newsmips
 news5000-% grep ^cpu0 /var/run/dmesg.boot
 cpu0 at mainbus0: MIPS R4400 CPU (0x450) Rev. 5.0 with MIPS R4010 FPC Rev. 0.0
 cpu0: 48 TLB entries, 16MB max page size
 cpu0: 16KB/16B direct-mapped L1 instruction cache
 cpu0: 16KB/16B direct-mapped write-back L1 data cache
 cpu0: 1024KB/64B direct-mapped write-back L2 unified cache
 news5000-% cat test.c 
 #include <stdio.h>
 
 int
 main(int argc, char *argv[])
 {
         float f;
 
         f = 3.14159 * 100;
         printf("%.1f\n", f);
         printf("%d\n", (int)f);
 
         f = f * 5;
         printf("%.1f\n", f);
         printf("%d\n", (int)f);
 }
 news5000-% cc test.c
 news5000-% ./a.out
 314.2
 314
 1570.8
 1570
 news5000-% 
 ---
 
 So the results imply this problem is R3000 (MIPS1) specific.
 
 ---
 Izumi Tsutsui
 


Home | Main Index | Thread Index | Old Index