Fix 1e parsing

Fix 1e5, 1e-5 evaluated as Infinity (https://github.com/HaxeFoundation/hscript/pull/132)
This commit is contained in:
Jaime Humberto Macias Bustamante
2025-04-10 14:51:36 -07:00
parent 6622220415
commit 34b07378fd
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -33,6 +33,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);
+2
View File
@@ -1943,6 +1943,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 ) {