mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-29 15:22:43 +00:00
Make strtof() respect the current rounding mode.
This commit is contained in:
parent
ae2cbf4c64
commit
9fb02073a3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=182710
@ -40,13 +40,21 @@ strtof(s, sp) CONST char *s; char **sp;
|
|||||||
strtof(CONST char *s, char **sp)
|
strtof(CONST char *s, char **sp)
|
||||||
#endif
|
#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];
|
ULong bits[1];
|
||||||
Long exp;
|
Long exp;
|
||||||
int k;
|
int k;
|
||||||
|
int Rounding = Flt_Rounds;
|
||||||
union { ULong L[1]; float f; } u;
|
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) {
|
switch(k & STRTOG_Retmask) {
|
||||||
case STRTOG_NoNumber:
|
case STRTOG_NoNumber:
|
||||||
case STRTOG_Zero:
|
case STRTOG_Zero:
|
||||||
|
Loading…
Reference in New Issue
Block a user