flt 1.5.2 → 1.5.3
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 +5 -5
- data/.travis.yml +4 -0
- data/History.txt +5 -0
- data/README.md +2 -2
- data/flt.gemspec +3 -3
- data/lib/flt/bigdecimal.rb +2 -2
- data/lib/flt/num.rb +1 -1
- data/lib/flt/tolerance.rb +1 -1
- data/lib/flt/version.rb +1 -1
- data/test/test_comparisons.rb +1 -1
- data/test/test_define_conversions.rb +19 -19
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ec3f00c70c9eb39227e1b5acf490afd57b9dcedfa3d4a1fe5b935debc6cafcd9
|
4
|
+
data.tar.gz: 94808cc1dfe07687d93ff0c98b247373223683cad4a603ee7bda1ba33534ed79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6f9272c9d849c240ff3697730e2465f4fbcbda9ebed66d75c6d36e866a02b5963cd664c0c0583e439747685c34562ed2ab83038f305ed12aa7a708848ec37c7
|
7
|
+
data.tar.gz: 1f1c4783c08ea9c324495d341884aae192e79e657b51eb7ac69ce74ab55fabbd2646c892194463e60041d8273687e57552a43f652973346ade4319b403b41652
|
data/.travis.yml
ADDED
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -361,7 +361,7 @@ DecNum.context.define_conversion_from(BigDecimal) do |x, context|
|
|
361
361
|
DecNum(x.to_s)
|
362
362
|
end
|
363
363
|
DecNum.context.define_conversion_to(BigDecimal) do |x|
|
364
|
-
BigDecimal
|
364
|
+
BigDecimal(x.to_s)
|
365
365
|
end
|
366
366
|
```
|
367
367
|
|
@@ -369,7 +369,7 @@ Now we can mix `BigDecimals` and `Decimals` in expressions and convert from `Dec
|
|
369
369
|
to `BigDecimal`:
|
370
370
|
|
371
371
|
```ruby
|
372
|
-
puts BigDecimal
|
372
|
+
puts BigDecimal('1.1') + DecNum('2.2') # -> 3.3
|
373
373
|
puts DecNum('1.1').convert_to(BigDecimal) # -> 0.11E1
|
374
374
|
```
|
375
375
|
|
data/flt.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "minitest", "
|
21
|
+
spec.add_development_dependency "bundler", ">= 1.9"
|
22
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
23
|
+
spec.add_development_dependency "minitest", ">= 5.10"
|
24
24
|
end
|
data/lib/flt/bigdecimal.rb
CHANGED
@@ -23,7 +23,7 @@ class Flt::BigDecimalContext
|
|
23
23
|
def Num(*args)
|
24
24
|
args = *args if args.size==1 && args.first.is_a?(Array)
|
25
25
|
if args.size > 1
|
26
|
-
BigDecimal
|
26
|
+
BigDecimal(Flt::DecNum(*args).to_s)
|
27
27
|
else
|
28
28
|
x = args.first
|
29
29
|
case x
|
@@ -32,7 +32,7 @@ class Flt::BigDecimalContext
|
|
32
32
|
when Rational
|
33
33
|
BigDecimal(x.numerator.to_s)/BigDecimal(x.denominator.to_s)
|
34
34
|
else
|
35
|
-
BigDecimal
|
35
|
+
BigDecimal(x.to_s)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/flt/num.rb
CHANGED
@@ -417,7 +417,7 @@ class Num < Numeric
|
|
417
417
|
# * :ignored_flags : a Flags object with the exceptions to be ignored
|
418
418
|
# * :emin, :emax : minimum and maximum adjusted exponents
|
419
419
|
# * :elimit : the exponent limits can also be defined by a single value;
|
420
|
-
# if positive it is taken as emax and emin=1-emax;
|
420
|
+
# if positive it is taken as emax and emin=1-emax; otherwise it is
|
421
421
|
# taken as emin and emax=1-emin. Such limits comply with IEEE 754-2008
|
422
422
|
# * :capitals : (true or false) to use capitals in text representations
|
423
423
|
# * :clamp : (true or false) enables clamping
|
data/lib/flt/tolerance.rb
CHANGED
data/lib/flt/version.rb
CHANGED
data/test/test_comparisons.rb
CHANGED
@@ -30,7 +30,7 @@ class TestComparisons < Minitest::Test
|
|
30
30
|
assert !(DecNum('1.1') == DecNum('1.0'))
|
31
31
|
#assert DecNum('1.1') == 1.1
|
32
32
|
#assert DecNum('1.0') == 1.0
|
33
|
-
#assert DecNum('1.0') == BigDecimal
|
33
|
+
#assert DecNum('1.0') == BigDecimal('1.000')
|
34
34
|
assert DecNum('1.0') == 1
|
35
35
|
assert DecNum('0.1') == Rational(1)/Rational(10)
|
36
36
|
|
@@ -32,22 +32,22 @@ class TestDefineConversions < Minitest::Test
|
|
32
32
|
DecNum.context.define_conversion_from(BigDecimal) do |x, context|
|
33
33
|
DecNum(x.to_s) # or use x.split etc.
|
34
34
|
end
|
35
|
-
assert DecNum('0') == BigDecimal
|
36
|
-
assert_equal BigDecimal
|
37
|
-
assert_equal BigDecimal
|
38
|
-
assert_equal BigDecimal
|
39
|
-
assert_equal BigDecimal
|
40
|
-
assert_equal DecNum('7.1'), BigDecimal
|
41
|
-
assert_equal DecNum('7.1'), DecNum('7')+BigDecimal
|
42
|
-
assert_equal DecNum('1.1'), DecNum(BigDecimal
|
43
|
-
assert DecNum(BigDecimal
|
35
|
+
assert DecNum('0') == BigDecimal('0')
|
36
|
+
assert_equal BigDecimal('0'), DecNum('0')
|
37
|
+
assert_equal BigDecimal('1.2345'), DecNum('1.2345')
|
38
|
+
assert_equal BigDecimal('-1.2345'), DecNum('-1.2345')
|
39
|
+
assert_equal BigDecimal('1.2345'), DecNum('0.0012345000E3')
|
40
|
+
assert_equal DecNum('7.1'), BigDecimal('7')+DecNum('0.1')
|
41
|
+
assert_equal DecNum('7.1'), DecNum('7')+BigDecimal('0.1')
|
42
|
+
assert_equal DecNum('1.1'), DecNum(BigDecimal('1.1'))
|
43
|
+
assert DecNum(BigDecimal('1.1')).is_a?(DecNum)
|
44
44
|
|
45
45
|
DecNum.context.define_conversion_to(BigDecimal) do |x|
|
46
|
-
BigDecimal
|
46
|
+
BigDecimal(x.to_s) # TODO: use x.split and handle special values
|
47
47
|
end
|
48
48
|
|
49
49
|
['0.1', '-0.1', '0.0', '1234567.1234567', '-1234567.1234567', '1.234E7', '1.234E-7'].each do |n|
|
50
|
-
f = BigDecimal
|
50
|
+
f = BigDecimal(n)
|
51
51
|
d = DecNum(n)
|
52
52
|
c = d.convert_to(BigDecimal)
|
53
53
|
assert c.is_a?(BigDecimal)
|
@@ -55,17 +55,17 @@ class TestDefineConversions < Minitest::Test
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
assert_raises(TypeError, RuntimeError) { DecNum('0') == BigDecimal
|
58
|
+
assert_raises(TypeError, RuntimeError) { DecNum('0') == BigDecimal('0') }
|
59
59
|
unless Num < Numeric
|
60
60
|
# BigDecimal#eql? is weird
|
61
|
-
refute_equal BigDecimal
|
62
|
-
refute_equal BigDecimal
|
63
|
-
refute_equal BigDecimal
|
64
|
-
refute_equal BigDecimal
|
65
|
-
assert_raises(TypeError) { BigDecimal
|
61
|
+
refute_equal BigDecimal('0'), DecNum('0')
|
62
|
+
refute_equal BigDecimal('1.2345'), DecNum('1.2345')
|
63
|
+
refute_equal BigDecimal('-1.2345'), DecNum('-1.2345')
|
64
|
+
refute_equal BigDecimal('1.2345'), DecNum('0.0012345000E3')
|
65
|
+
assert_raises(TypeError) { BigDecimal('7')+DecNum('0.1') }
|
66
66
|
end
|
67
|
-
assert_raises(TypeError, RuntimeError) { DecNum('7')+BigDecimal
|
68
|
-
assert_raises(TypeError, RuntimeError) { DecNum(BigDecimal
|
67
|
+
assert_raises(TypeError, RuntimeError) { DecNum('7')+BigDecimal('0.1') }
|
68
|
+
assert_raises(TypeError, RuntimeError) { DecNum(BigDecimal('1.1')) }
|
69
69
|
|
70
70
|
['0.1', '-0.1', '0.0', '1234567.1234567', '-1234567.1234567', '1.234E7', '1.234E-7'].each do |n|
|
71
71
|
assert_raises(TypeError, RuntimeError) { DecNum(n).convert_to(BigDecimal) }
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Goizueta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.9'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 12.3.3
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 12.3.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '5.10'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.10'
|
55
55
|
description: Decimal and binary arbitrary precision floating point numbers in pure
|
@@ -61,6 +61,7 @@ extensions: []
|
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
63
|
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
64
65
|
- Gemfile
|
65
66
|
- History.txt
|
66
67
|
- License.txt
|
@@ -143,8 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
144
|
- !ruby/object:Gem::Version
|
144
145
|
version: '0'
|
145
146
|
requirements: []
|
146
|
-
|
147
|
-
rubygems_version: 2.6.8
|
147
|
+
rubygems_version: 3.1.2
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Floating Point Numbers
|