Skip to content

Commit 34b0737

Browse files
committed
Fix 1e parsing
Fix 1e5, 1e-5 evaluated as Infinity (HaxeFoundation#132)
1 parent 6622220 commit 34b0737

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

TestHScript.hx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ class TestHScript extends TestCase {
3333
assertScript("- 123",-123);
3434
assertScript("1.546",1.546);
3535
assertScript(".545",.545);
36+
assertScript("1e5",100000);
37+
assertScript("1.2e2",120);
38+
assertScript("100e-2",1);
39+
assertScript("1.2e-1",0.12);
3640
assertScript("'bla'","bla");
3741
assertScript("null",null);
3842
assertScript("true",true);

hscript/Parser.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,8 @@ class Parser {
19431943
}
19441944
if( pow == null )
19451945
invalidChar(char);
1946+
if( exp == 0 )
1947+
exp = 10;
19461948
return TConst(CFloat((Math.pow(10, pow) / exp) * n * 10));
19471949
case ".".code:
19481950
if( exp > 0 ) {

0 commit comments

Comments
 (0)