Skip to content

Commit

Permalink
fix: {.calc.} not working with very small numbers (because rendered w…
Browse files Browse the repository at this point in the history
…ith exponential syntax)
  • Loading branch information
rejetto committed Jun 16, 2020
1 parent 65d4a14 commit 26ddc2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 1 addition & 4 deletions scriptLib.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1962,10 +1962,7 @@ function cbMacros(fullMacro:string; pars:Tstrings; cbData:pointer):string;
begin
try
if isFalse(parEx('if')) then
begin
result:='';
exit;
end;
exit('');
except end;
result:=md.cd.disconnectReason; // return the previous state
if pars.count > 0 then md.cd.disconnectReason:=p;
Expand Down
4 changes: 3 additions & 1 deletion utillib.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2576,7 +2576,8 @@ function evalFormula(s:string):real;
i:=mImp+dir;
repeat
j:=i+dir;
if (j > 0) and (j <= length(s)) and charInSet(s[j], ['0'..'9','.']) then
if (j > 0) and (j <= length(s))
and (charInSet(s[j], ['0'..'9','.','E']) or (j>1) and charInSet(s[j],['+','-']) and (s[j-1]='E')) then
i:=j
else
break;
Expand Down Expand Up @@ -2606,6 +2607,7 @@ function evalFormula(s:string):real;
end;

if (i = 1) // a starting operator is not an operator
or (s[i-1]='E') // exponential syntax
or (v <= mImpV) // left-to-right precedence
then continue;
// we got a better one, record it
Expand Down

0 comments on commit 26ddc2b

Please sign in to comment.