diff --git a/src/currency.js b/src/currency.js index 1edc89fe..7668252a 100644 --- a/src/currency.js +++ b/src/currency.js @@ -138,12 +138,17 @@ currency.prototype = { /** * Divides value. - * @param {number} number + * @param {number|currency} value * @returns {currency} */ - divide(number) { + divide(value) { let { intValue, _settings } = this; - return currency(intValue /= parse(number, _settings, false), _settings); + + if (value instanceof currency) { + return intValue / parse(value, _settings, false); + } + + return currency(intValue /= parse(value, _settings, false), _settings); }, /** diff --git a/test/test.js b/test/test.js index ce1d38ca..a8d94d75 100644 --- a/test/test.js +++ b/test/test.js @@ -555,4 +555,8 @@ test('should handle fractional cents', t => { var values = currency(1234.56, { fromCents: true }); t.is(values.intValue, 1235); t.is(values.value, 12.35); +}); + +test('division by currency should result in a number, not currency', t => { + t.is(currency(110).divide(currency(20)), 5.5); }); \ No newline at end of file