In scanf, round according to the current rounding mode.
This commit is contained in:
parent
7c103000b6
commit
9c90f85a6b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=174204
@ -4,6 +4,6 @@
|
||||
#
|
||||
|
||||
# Long double is 80 bits
|
||||
GDTOASRCS+=strtopx.c
|
||||
GDTOASRCS+=strtorx.c
|
||||
MDSRCS+=machdep_ldisx.c
|
||||
SYM_MAPS+=${.CURDIR}/amd64/Symbol.map
|
||||
|
@ -46,11 +46,11 @@ char *
|
||||
__ldtoa(long double *ld, int mode, int ndigits, int *decpt, int *sign,
|
||||
char **rve)
|
||||
{
|
||||
static FPI fpi = {
|
||||
FPI fpi = {
|
||||
LDBL_MANT_DIG, /* nbits */
|
||||
LDBL_MIN_EXP - LDBL_MANT_DIG, /* emin */
|
||||
LDBL_MAX_EXP - LDBL_MANT_DIG, /* emax */
|
||||
FPI_Round_near, /* rounding */
|
||||
FLT_ROUNDS, /* rounding */
|
||||
#ifdef Sudden_Underflow /* unused, but correct anyway */
|
||||
1
|
||||
#else
|
||||
@ -64,7 +64,15 @@ __ldtoa(long double *ld, int mode, int ndigits, int *decpt, int *sign,
|
||||
void *vbits = bits;
|
||||
|
||||
u.e = *ld;
|
||||
|
||||
/*
|
||||
* gdtoa doesn't know anything about the sign of the number, so
|
||||
* if the number is negative, we need to swap rounding modes of
|
||||
* 2 (upwards) and 3 (downwards).
|
||||
*/
|
||||
*sign = u.bits.sign;
|
||||
fpi.rounding ^= (fpi.rounding >> 1) & u.bits.sign;
|
||||
|
||||
be = u.bits.exp - (LDBL_MAX_EXP - 1) - (LDBL_MANT_DIG - 1);
|
||||
LDBL_TO_ARRAY32(u, bits);
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include "gdtoaimp.h"
|
||||
|
||||
long double
|
||||
@ -40,6 +42,6 @@ strtold(const char * __restrict s, char ** __restrict sp)
|
||||
{
|
||||
long double result;
|
||||
|
||||
strtopQ(s, sp, &result);
|
||||
strtorQ(s, sp, FLT_ROUNDS, &result);
|
||||
return result;
|
||||
}
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include "gdtoaimp.h"
|
||||
|
||||
long double
|
||||
@ -40,6 +42,6 @@ strtold(const char * __restrict s, char ** __restrict sp)
|
||||
{
|
||||
long double result;
|
||||
|
||||
strtopx(s, sp, &result);
|
||||
strtorx(s, sp, FLT_ROUNDS, &result);
|
||||
return result;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
# $FreeBSD$
|
||||
|
||||
# Long double is 80 bits
|
||||
GDTOASRCS+=strtopx.c
|
||||
GDTOASRCS+=strtorx.c
|
||||
MDSRCS+=machdep_ldisx.c
|
||||
SYM_MAPS+=${.CURDIR}/i386/Symbol.map
|
||||
|
@ -4,6 +4,6 @@
|
||||
#
|
||||
|
||||
# Long double is 80 bits
|
||||
GDTOASRCS+=strtopx.c
|
||||
GDTOASRCS+=strtorx.c
|
||||
MDSRCS+=machdep_ldisx.c
|
||||
SYM_MAPS+=${.CURDIR}/ia64/Symbol.map
|
||||
|
@ -6,6 +6,6 @@
|
||||
.include "fpu/Makefile.inc"
|
||||
|
||||
# Long double is quad precision
|
||||
GDTOASRCS+=strtopQ.c
|
||||
GDTOASRCS+=strtorQ.c
|
||||
MDSRCS+=machdep_ldisQ.c
|
||||
SYM_MAPS+=${.CURDIR}/sparc64/Symbol.map
|
||||
|
Loading…
Reference in New Issue
Block a user