Skip to content

Commit 78d5cbd

Browse files
authored
Fix 1e5, 1e-5 evaluated as Infinity (#132)
1 parent f6f8ba9 commit 78d5cbd

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
@@ -49,6 +49,10 @@ class TestHScript extends TestCase {
4949
assertScript("- 123",-123);
5050
assertScript("1.546",1.546);
5151
assertScript(".545",.545);
52+
assertScript("1e5",100000);
53+
assertScript("1.2e2",120);
54+
assertScript("100e-2",1);
55+
assertScript("1.2e-1",0.12);
5256
assertScript("'bla'","bla");
5357
assertScript("null",null);
5458
assertScript("true",true);

hscript/Parser.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,8 @@ class Parser {
13931393
}
13941394
if( pow == null )
13951395
invalidChar(char);
1396+
if( exp == 0 )
1397+
exp = 10;
13961398
return TConst(CFloat((Math.pow(10, pow) / exp) * n * 10));
13971399
case ".".code:
13981400
if( exp > 0 ) {

0 commit comments

Comments
 (0)