monies 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/monies.rb +3 -1
  3. data/monies.gemspec +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 457a633b330a9b30ecebac6694ed2b29566e96ed3db33b3ba2a8feca86501c88
4
- data.tar.gz: 9b3fe5366065d52108a6b3b6d74f0daba814174f47063ce12dfac75d10ecb132
3
+ metadata.gz: 4ffee4b91733b331056188aef0f3576b9e90fc16847f91174749f7ffc154e7ff
4
+ data.tar.gz: bac13063005ebde101cf5faa4405fcfe48c1107bb10e6568ae35fe9c51191ce7
5
5
  SHA512:
6
- metadata.gz: ef772a5e785576896d10adc3638aa7062f9e148cf6678394c82e2d5f1555ea486822cc1bc018b3babc3c3976480d6fb8b7fff15bf4c315861b175c4f996ffbf2
7
- data.tar.gz: a69ffff9d64b66179c71bdeb7d4443a594818523e7d54ba845d3ad7cebf9f580cdd86173be0a7cb68a5ed4078262946620f8908fbc2c58a86254e60a60ae248e
6
+ metadata.gz: e7a50b0b8c9584a16dc75be18bac0e54f706028cda755d501e8e91f3a2c84487b4b4763ac6ba651c36ccb70b2b275baa445983133982d926efb299653989611b
7
+ data.tar.gz: 9a1f89469a73048e45e55cd6db7e3a93b4e2cfc99a9a5dbf6d247e56ee89f68ddea4bd76b66d819e8e844f5967911878a88c7a12996743923416e475d56db57d
data/lib/monies.rb CHANGED
@@ -389,7 +389,7 @@ class Monies
389
389
  def divide(value, scale, divisor, max_scale)
390
390
  quotient, carry = 0, 0
391
391
 
392
- value.digits.reverse_each do |digit|
392
+ value.abs.digits.reverse_each do |digit|
393
393
  dividend = carry + digit
394
394
 
395
395
  quotient = (quotient * BASE) + (dividend / divisor)
@@ -411,6 +411,8 @@ class Monies
411
411
  iterations -= 1
412
412
  end
413
413
 
414
+ quotient = -quotient if value.negative?
415
+
414
416
  self.class.new(quotient, scale, @currency)
415
417
  end
416
418
 
data/monies.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'monies'
3
- s.version = '1.0.0'
3
+ s.version = '1.0.1'
4
4
  s.license = 'LGPL-3.0'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ['Tim Craft']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monies
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Craft