mat-package
Version:
Pacote com funções para cálculos matemáticos.
33 lines (32 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.subtracao = exports.divisao = exports.multiplicacao = exports.soma = void 0;
const Validator_1 = require("../Validator");
const CORRETOR = 1000000000000;
const soma = (n1, n2) => {
(0, Validator_1.validatorOperacoes)(n1, n2);
const result = (n1 * CORRETOR + n2 * CORRETOR) / CORRETOR;
return result;
};
exports.soma = soma;
const multiplicacao = (n1, n2) => {
(0, Validator_1.validatorOperacoes)(n1, n2);
const result = (n1 * CORRETOR * n2 * CORRETOR) / (CORRETOR * CORRETOR);
return result;
};
exports.multiplicacao = multiplicacao;
const divisao = (n1, n2) => {
(0, Validator_1.validatorOperacoes)(n1, n2);
if (n2 === 0) {
throw new Error("Não é possível dividir por zero");
}
const result = (n1 * CORRETOR) / (n2 * CORRETOR);
return result;
};
exports.divisao = divisao;
const subtracao = (n1, n2) => {
(0, Validator_1.validatorOperacoes)(n1, n2);
const result = (n1 * CORRETOR - n2 * CORRETOR) / CORRETOR;
return result;
};
exports.subtracao = subtracao;