numeric_inverse 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6812f73ad5b41503887625a8f56000c69998949545fe730cfe4e2f914ea656b6
4
- data.tar.gz: a81ca2caa95703d0831a27e429546e7cfbb24d71b8536fb376b6a24e168a6ac7
3
+ metadata.gz: d9d307197855922802b9ff55008ae70b4d9aa08da00baeefb55ea5d108c42d05
4
+ data.tar.gz: 5cb7fee4b7bc2927eb7eb9019fefbe31b50cb19b5a9bdf54781733dfcbfaa626
5
5
  SHA512:
6
- metadata.gz: 0dcc87bd3d88f0569b2ec72ff895b484f64eda6107dff9df584f79597465a10a3c2d1b5320913203b1043f2e740e28103b333001522f49ad58d03a20c25d0384
7
- data.tar.gz: ca5d98880c6546f7ca6b89ee50535b676e584fbe3038703b21fb1a5daa264d32ae66e4be6ae264cf9cffef436ca94b13faf9b87e1145333feb45ead1b78a9664
6
+ metadata.gz: e9b6b55c587d20f2e99072d234efce8d573a21b304f0de5e147ad674f24d03cc9352767ca3b379922e5034152be8cfe9b7335f98fb38467c8890ab75b1ebc7c8
7
+ data.tar.gz: e1d79f91b178c6de2c4dafa3de49c7d984a2985539ebd919aba467f852f732a094c422edc234bf3f5bb0072ed513237d733778c19339e6dc4a1540a2343e6366
data/README.md CHANGED
@@ -55,7 +55,7 @@ p 63.inv(100) #=> 27
55
55
  p 63.inv(100) * 63 #=> 1701
56
56
  p 63.inv(100) * 63 % 100 #=> 1
57
57
 
58
- p 64.inv(100) #=> ArgumentError: modulus 100 is not coprime to 64
58
+ p 64.inv(100) #=> ArgumentError: modulus is not coprime to the receiver
59
59
  ```
60
60
 
61
61
  ## Development
@@ -27,11 +27,11 @@ module NumericInverse
27
27
  # x is an inverse iff self.gcd(m) == 1
28
28
  if a.abs != 1
29
29
  raise ArgumentError,
30
- "modulus #{m} is not coprime to #{self}"
30
+ "modulus is not coprime to the receiver"
31
31
  end
32
32
 
33
33
  x = -x if a < 0
34
- x % m.abs # 0 <= x < |m|
34
+ x % m # 0 <= x < m || m < x <= 0
35
35
  end
36
36
 
37
37
  alias inv inverse
@@ -20,7 +20,7 @@ class Integer
20
20
  # 63.inv(100) * 63 #=> 1701
21
21
  # 63.inv(100) * 63 % 100 #=> 1
22
22
  #
23
- # 64.inv(100) #=> ArgumentError: modulus 100 is not coprime to 64
23
+ # 64.inv(100) #=> ArgumentError: modulus is not coprime to the receiver
24
24
  #
25
25
  def inverse(m = nil)
26
26
  return Rational(1, self) if m.nil?
@@ -35,11 +35,11 @@ class Integer
35
35
  # x is an inverse iff self.gcd(m) == 1
36
36
  if a.abs != 1
37
37
  raise ArgumentError,
38
- "modulus #{m} is not coprime to #{self}"
38
+ "modulus is not coprime to the receiver"
39
39
  end
40
40
 
41
41
  x = -x if a < 0
42
- x % m.abs # 0 <= x < |m|
42
+ x % m # 0 <= x < m || m < x <= 0
43
43
  end
44
44
 
45
45
  alias inv inverse
@@ -1,3 +1,3 @@
1
1
  module NumericInverse
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numeric_inverse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Nomoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-05 00:00:00.000000000 Z
11
+ date: 2019-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,7 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
96
  requirements: []
97
- rubygems_version: 3.0.1
97
+ rubyforge_project:
98
+ rubygems_version: 2.7.6
98
99
  signing_key:
99
100
  specification_version: 4
100
101
  summary: Define `Numeric#inverse` to return its multiplicative inverse