Skip to content

Commit

Permalink
Fix 1e5, 1e-5 evaluated as Infinity (HaxeFoundation#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiaomao authored Dec 10, 2024
1 parent f6f8ba9 commit 78d5cbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions TestHScript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class TestHScript extends TestCase {
assertScript("- 123",-123);
assertScript("1.546",1.546);
assertScript(".545",.545);
assertScript("1e5",100000);
assertScript("1.2e2",120);
assertScript("100e-2",1);
assertScript("1.2e-1",0.12);
assertScript("'bla'","bla");
assertScript("null",null);
assertScript("true",true);
Expand Down
2 changes: 2 additions & 0 deletions hscript/Parser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,8 @@ class Parser {
}
if( pow == null )
invalidChar(char);
if( exp == 0 )
exp = 10;
return TConst(CFloat((Math.pow(10, pow) / exp) * n * 10));
case ".".code:
if( exp > 0 ) {
Expand Down

0 comments on commit 78d5cbd

Please sign in to comment.