* fixed r20701 for targets having no extended type

git-svn-id: trunk@20705 -
This commit is contained in:
florian 2012-04-04 19:41:59 +00:00
parent b2ed134379
commit e2af17e6f6

View File

@ -1374,6 +1374,7 @@ end;
Function fpc_Val_Real_ShortStr(const s : shortstring; out Code : ValSInt): ValReal; [public, alias:'FPC_VAL_REAL_SHORTSTR']; compilerproc;
var
hd,
sign : valreal;
esign,
exponent,
@ -1465,7 +1466,28 @@ begin
fpc_Val_Real_ShortStr:=fpc_Val_Real_ShortStr*sign;
{ Calculate Exponent }
fpc_Val_Real_ShortStr:=mul_by_power10(fpc_Val_Real_ShortStr,exponent*esign);
hd:=1.0;
{ the magnitude range maximum (normal) is lower in absolute value than the }
{ the magnitude range minimum (denormal). E.g. an extended value can go }
{ up to 1E4932, but "down" to 1E-4951. So make sure that we don't try to }
{ calculate 1E4951 as factor, since that would overflow and result in 0. }
if (exponent>valmaxexpnorm-2) then
begin
hd:=mul_by_power10(hd,valmaxexpnorm-2);
if esign>0 then
fpc_Val_Real_ShortStr:=fpc_Val_Real_ShortStr*hd
else
fpc_Val_Real_ShortStr:=fpc_Val_Real_ShortStr/hd;
dec(exponent,valmaxexpnorm-2);
hd:=1.0;
end;
hd:=mul_by_power10(hd,exponent);
if esign>0 then
fpc_Val_Real_ShortStr:=fpc_Val_Real_ShortStr*hd
else
fpc_Val_Real_ShortStr:=fpc_Val_Real_ShortStr/hd;
{ Not all characters are read ? }
if length(s)>=code then