How to use the number function from mathjs
Find comprehensive JavaScript mathjs.number code examples handpicked from public code repositorys.
GitHub: hollaex/hollaex-kit
17 18 19 20 21 22 23 24 25 26
const sumOrderTotal = (orders) => orders.reduce( (total, [price, size]) => math.add( total, math.number(math.multiply(math.fraction(size), math.fraction(price))) ), 0 );
211
236
0
+ 3 other calls in file
GitHub: hollaex/hollaex-kit
89 90 91 92 93 94 95 96 97 98 99 100 101
return res; } const getUserQuickTrade = async (spending_currency, spending_amount, receiving_amount, receiving_currency, bearerToken, ip, opts) => { if (spending_amount) spending_amount = math.number(spending_amount); if (receiving_amount) receiving_amount = math.number(receiving_amount); const originalPair = `${spending_currency}-${receiving_currency}`; const flippedPair = `${receiving_currency}-${spending_currency}`;
206
234
14
+ 9 other calls in file
GitHub: Fermium/mathlion
59 60 61 62 63 64 65 66 67 68
} if (math.typeof(evaluated[0]) == 'Unit') { //math.autoscale(evaluated); unit = ' [' + evaluated[0].toJSON().unit + ']'; evaluated = _.map(evaluated,function(ev){ return math.number(ev,ev.toJSON().unit); }); } if (math.typeof(evaluated) == 'Unit') {
23
77
11
+ 11 other calls in file
GitHub: invizi/invizi
21 22 23 24 25 26 27 28 29 30
attrExtractor (attrName) { return obj => obj[attrName] }, add (a, b) { return math.number(math.add(math.bignumber(a), math.bignumber(b))) } } InviziLambda.sumFromObj = R.compose(R.reduce(InviziLambda.add, 0), R.values, R.map) InviziLambda.sumArray = R.compose(R.reduce(InviziLambda.add, 0), R.map)
19
62
5
+ 3 other calls in file
83 84 85 86 87 88 89 90 91 92
export function matrix_nul(mat: math.Matrix) { let reduced: math.Matrix = gauss_elimination(mat); reduced = reduced.map(function (value) { return math.number(value); }); let free_variables: number[] = []; let free_variable_count: number = 0; // initlize loop and determine location of free variables
0
5
2
72 73 74 75 76 77 78 79 80 81
let initialX = math.number(ctx[variable]); ctx[variable] = initialX - DERIVATIVE_H; let f1 = math.number(math.eval(expression.toString(), ctx)); ctx[variable] = initialX + DERIVATIVE_H; let f2 = math.number(math.eval(expression.toString(), ctx)); return (f2 - f1) / (2 * DERIVATIVE_H); } throw new Error('Function ' + expression + ' is not supported by derivative, or a wrong number of arguments is passed');
0
0
5
+ 111 other calls in file
194 195 196 197 198 199 200 201 202 203
}, binomialpdf: function (trials, probSuccess, x) { /* @help Probability of getting exactly x successes in a binomial setting */ /* Normalize numbers */ x = math.number(x); trials = math.number(trials); probSuccess = math.number(probSuccess); if (probSuccess <= 0 || probSuccess > 1) throw new RangeError('0 < probSuccess < 1 must be true');
0
0
5
+ 113 other calls in file
GitHub: AlexKliger/mathomizer
122 123 124 125 126 127 128 129 130 131
answer = math.multiply(valueL, valueR) } else if (this instanceof DivideBy) { answer = math.divide(valueL, valueR) } return this.answerFormat === 'ratio' ? answer : math.number(answer) } #getWrongAnswer(answer) { let wrongAnswer, offset
0
0
0
544 545 546 547 548 549 550 551 552 553
'toolsLib/wallet/withdrawalBelowLimit', `total 24 hour ${currency} withdrawn amount`, last24HourWithdrawalAmount ); let totalWithdrawalAmount = math.number( math.add( math.bignumber(amount), math.bignumber(last24HourWithdrawalAmount) )
0
0
1
+ 365 other calls in file
mathjs.evaluate is the most popular function in mathjs (87200 examples)