- Implement the upcoming
JSON.Encoderprotocol
- Add
Decimal.gte?/2andDecimal.lte?/2 - Add
Decimal.compare/3andDecimal.eq?/3with threshold as parameter
Decimal v2.1 requires Elixir v1.8+.
- Fix
Decimal.compare/2when comparing against0
Decimal v2.1 requires Elixir v1.8+.
- Improve error message from
Decimal.to_integer/1during precision loss Inspectprotocol implementation returns strings in theDecimal.new(...)format- Add
Decimal.scale/1 - Optimize
Decimal.compare/2for numbers with large exponents
- Fix
Decimal.integer?/1spec - Fix
Decimal.integer?/1check on 0 with >1 significant digits
Decimal v2.0 requires Elixir v1.2+.
- Add
Decimal.integer?/1
- Change
Decimal.compare/2to return:lt | :eq | :gt - Change
Decimal.cast/1to return{:ok, t} | :error - Change
Decimal.parse/1to return{t, binary} | :error - Remove
:messageand:resultfields fromDecimal.Error - Remove sNaN
- Rename qNaN to NaN
- Remove deprecated support for floats in
Decimal.new/1 - Remove deprecated
Decimal.minus/1 - Remove deprecated
Decimal.plus/1 - Remove deprecated
Decimal.reduce/1 - Remove deprecated
Decimal.with_context/2,Decimal.get_context/1,Decimal.set_context/1, andDecimal.update_context/1 - Remove deprecated
Decimal.decimal?/1
- Deprecate
Decimal.cmp/2
- Add
Decimal.negate/1 - Add
Decimal.apply_context/1 - Add
Decimal.normalize/1 - Add
Decimal.Context.with/2,Decimal.Context.get/1,Decimal.Context.set/2, andDecimal.Context.update/1 - Add
Decimal.is_decimal/1
- Deprecate
Decimal.minus/1in favour of the newDecimal.negate/1 - Deprecate
Decimal.plus/1in favour of the newDecimal.apply_context/1 - Deprecate
Decimal.reduce/1in favour of the newDecimal.normalize/1 - Deprecate
Decimal.with_context/2,Decimal.get_context/1,Decimal.set_context/2, andDecimal.update_context/1in favour of new functions on theDecimal.Contextmodule - Deprecate
Decimal.decimal?/1in favour of the newDecimal.is_decimal/1
- Fix Decimal.compare/2 with string arguments
- Set :signal on error
- Add
Decimal.cast/1 - Add
Decimal.eq?/2,Decimal.gt?/2, andDecimal.lt?/2 - Add guards to
Decimal.new/3to prevent invalid Decimal numbers
- Add
Decimal.sqrt/1
- Support for canonical XSD representation on
Decimal.to_string/2
- Fix exponent off-by-one when converting from decimal to float
- Fix negative?/1 and positive?/1 specs
- Deprecate passing float to
Decimal.new/1in favor ofDecimal.from_float/1
- Add
Decimal.positive?/1andDecimal.negative?/1 - Accept integers and strings in arithmetic functions, e.g.:
Decimal.add(1, "2.0") - Add
Decimal.from_float/1
- Soft deprecate passing float to
new/1in favor offrom_float/1
- Include the given value as part of the error reason
- Fix
:half_even:lists.lastbug (empty signif) - Fix error message for round
- Fix
:half_downrounding error when remainder is greater than 5 - Fix
Decimal.new/1float conversion with bigger precision than 4 - Fix precision default value
- Fix
Decimal.to_integer/1for large coefficients - Fix rounding of ~0 values
- Fix errors when comparing and adding two infinities