kgl 0.0.4 → 0.0.5
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 +4 -4
- data/CHANGELOG.md +4 -1
- data/lib/kgl/kmath.rb +6 -0
- data/lib/kgl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a7096ca78114cdf718f0c28ebea651c3883beb97e661fac637797ed97320713
|
|
4
|
+
data.tar.gz: 913f01ff7a69aa1b7ce27ae4e1bcc6670b30aabd9711b78fa61b2fd66d4317e7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5ed96a95a203a6509d2c2a198b39c441e7704fee12e20eb9e7686b423f5824a8738cfefdc73e37acc88b42e81f297eb93151cf0f9cc6c198d513d7cb54ca8533
|
|
7
|
+
data.tar.gz: 6d88af36b4a74a21f91711bc3a1ff1ec11b09cc1f59ce6c649bf293032bc7b1073caabefa8f7ecf31ccc71c74b5529b825fff3519c758584ab320803743d58df
|
data/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 0.0.5 2026/04/12
|
|
4
|
+
- `Float#to_r` and `Float#to_r_exact` raise `FloatDomainError` when `self` is not finite.
|
|
5
|
+
|
|
3
6
|
## 0.0.4 2026/04/02
|
|
4
|
-
- Add `Float#to_r_exact` that returns exact Rational value expressed by self
|
|
7
|
+
- Add `Float#to_r_exact` that returns exact Rational value expressed by `self`.
|
|
5
8
|
|
|
6
9
|
## 0.0.3 2024/12/03
|
|
7
10
|
- Add `Kgl.#rpw`.
|
data/lib/kgl/kmath.rb
CHANGED
|
@@ -15,6 +15,9 @@ end
|
|
|
15
15
|
|
|
16
16
|
class Float
|
|
17
17
|
def to_r
|
|
18
|
+
unless self.finite?
|
|
19
|
+
raise FloatDomainError
|
|
20
|
+
end
|
|
18
21
|
str = self.to_s
|
|
19
22
|
(decimal, power) = str.split(/e/)
|
|
20
23
|
(integer, decimal) = decimal.split(/\./)
|
|
@@ -30,6 +33,9 @@ class Float
|
|
|
30
33
|
return Rational(numerator, denominator)
|
|
31
34
|
end
|
|
32
35
|
def to_r_exact
|
|
36
|
+
unless self.finite?
|
|
37
|
+
raise FloatDomainError
|
|
38
|
+
end
|
|
33
39
|
s, e = Math.frexp(self)
|
|
34
40
|
if e < 53
|
|
35
41
|
Rational(Math.ldexp(s, 53).to_i, 1<<(53-e))
|
data/lib/kgl/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kgl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- KAZOON
|
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
93
93
|
- !ruby/object:Gem::Version
|
|
94
94
|
version: '0'
|
|
95
95
|
requirements: []
|
|
96
|
-
rubygems_version: 4.0.
|
|
96
|
+
rubygems_version: 4.0.10
|
|
97
97
|
specification_version: 4
|
|
98
98
|
summary: A gem for personal use.
|
|
99
99
|
test_files: []
|