mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-08 04:01:51 +09:00
basic: exponentiation to raise correct errors
This commit is contained in:
@@ -687,7 +687,12 @@ if no arg text were given (e.g. "10 NEXT"), args will have zero length
|
||||
});
|
||||
},
|
||||
"^" : function(lnum, stmtnum, args) {
|
||||
return twoArgNum(lnum, stmtnum, args, (lh,rh) => Math.pow(lh, rh));
|
||||
return twoArgNum(lnum, stmtnum, args, (lh,rh) => {
|
||||
let r = Math.pow(lh, rh);
|
||||
if (isNaN(r)) throw lang.badFunctionCallFormat();
|
||||
if (!isFinite(r)) throw lang.divByZero;
|
||||
return r;
|
||||
});
|
||||
},
|
||||
"TO" : function(lnum, stmtnum, args) {
|
||||
return twoArgNum(lnum, stmtnum, args, (from, to) => new ForGen(from, to, 1));
|
||||
|
||||
Reference in New Issue
Block a user