summaryrefslogtreecommitdiffstats
path: root/contrib/gdtoa/strtof.c
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2008-09-03 07:32:06 +0000
committerdas <das@FreeBSD.org>2008-09-03 07:32:06 +0000
commit65b5df780e46482cb390f068a30dd18da539fa2e (patch)
tree33641ebe9c53fac1ea3bbd0e3153ae9d1e0900c6 /contrib/gdtoa/strtof.c
parent2732388653bc1d73e3e22df8de7d745845b3f37f (diff)
downloadFreeBSD-src-65b5df780e46482cb390f068a30dd18da539fa2e.zip
FreeBSD-src-65b5df780e46482cb390f068a30dd18da539fa2e.tar.gz
Make strtof() respect the current rounding mode.
Diffstat (limited to 'contrib/gdtoa/strtof.c')
-rw-r--r--contrib/gdtoa/strtof.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/contrib/gdtoa/strtof.c b/contrib/gdtoa/strtof.c
index 58486f2..727a3fa 100644
--- a/contrib/gdtoa/strtof.c
+++ b/contrib/gdtoa/strtof.c
@@ -40,13 +40,21 @@ strtof(s, sp) CONST char *s; char **sp;
strtof(CONST char *s, char **sp)
#endif
{
- static FPI fpi = { 24, 1-127-24+1, 254-127-24+1, 1, SI };
+ static FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI };
+ FPI *fpi, fpi1;
ULong bits[1];
Long exp;
int k;
+ int Rounding = Flt_Rounds;
union { ULong L[1]; float f; } u;
- k = strtodg(s, sp, &fpi, &exp, bits);
+ fpi = &fpi0;
+ if (Rounding != FPI_Round_near) {
+ fpi1 = fpi0;
+ fpi1.rounding = Rounding;
+ fpi = &fpi1;
+ }
+ k = strtodg(s, sp, fpi, &exp, bits);
switch(k & STRTOG_Retmask) {
case STRTOG_NoNumber:
case STRTOG_Zero:
OpenPOWER on IntegriCloud