@@ -3510,6 +3510,11 @@ var math = Numbas.math = /** @lends Numbas.math */ {
35103510 * @returns {boolean}
35113511 */
35123512 withinTolerance: function(a, b, tolerance) {
3513+ if(a.complex || b.complex) {
3514+ a = a.complex ? a : math.complex(a,0);
3515+ b = b.complex ? b : math.complex(b,0);
3516+ return math.withinTolerance(a.re, b.re, tolerance) && math.withinTolerance(a.im, b.im, tolerance);
3517+ }
35133518 if(tolerance == 0) {
35143519 return math.eq(a, b);
35153520 } else {
@@ -9509,6 +9514,8 @@ var jme = Numbas.jme = /** @lends Numbas.jme */ {
95099514 }
95109515 } else if(v instanceof math.ComplexDecimal) {
95119516 return new jme.types.TDecimal(v);
9517+ } else if(typeof v == 'object' && v && v.complex && v.hasOwnProperty('re') && v.hasOwnProperty('im')) {
9518+ return new jme.types.TNum(v);
95129519 } else if(v instanceof Decimal) {
95139520 return new jme.types.TDecimal(v);
95149521 } else if(v instanceof math.Fraction) {
@@ -11181,6 +11188,9 @@ Scope.prototype = /** @lends Numbas.jme.Scope.prototype */ {
1118111188 */
1118211189 getFunction: function(name) {
1118311190 name = jme.normaliseName(name, this);
11191+ if(jme.funcSynonyms[name]) {
11192+ name = jme.funcSynonyms[name];
11193+ }
1118411194 if(!this._resolved_functions[name]) {
1118511195 var scope = this;
1118611196 var o = [];
@@ -15658,6 +15668,9 @@ newBuiltin('countsigfigs', [TString], TNum, function(s) {
1565815668 return math.countSigFigs(util.cleanNumber(s));
1565915669});
1566015670newBuiltin('isnan', [TNum], TBool, function(n) {
15671+ if(n.complex) {
15672+ return isNaN(n.re) || isNaN(n.im);
15673+ }
1566115674 return isNaN(n);
1566215675});
1566315676newBuiltin('matchnumber', [TString, sig.listof(sig.type('string'))], TList, function(s, styles) {
0 commit comments