flt 1.4.6 → 1.4.7
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/History.txt +6 -1
- data/lib/flt/num.rb +4 -3
- data/lib/flt/version.rb +1 -1
- data/test/test_basic.rb +14 -0
- data/test/test_hex_format.rb +9 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a82d3975aca56adcdeefe93da5fed92f8adb4159
|
4
|
+
data.tar.gz: 2155cf086a59dc59ce6f01e19b00b546c58a77e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1b9044b8b0deafd52eac4f3b481bbd360e9fd70ed7fb70f7489ed7744cf40fce81218275b402c7547d57d7fabc4bc2cde078ed5faebcb21a814be559edd7ed8
|
7
|
+
data.tar.gz: 07196b48dcb47e16a745f0488b2cddb8b60e91056de66d020a12bfb9e5cbd27a57c5f36b21b9a7f8cc69815caa04a8708c999df6cca70a5f337642c32000a0aa
|
data/History.txt
CHANGED
data/lib/flt/num.rb
CHANGED
@@ -2429,7 +2429,7 @@ class Num < Numeric
|
|
2429
2429
|
context = define_context(context)
|
2430
2430
|
return Num(self) if self.special? || self.zero? || context.exact?
|
2431
2431
|
sign, coeff, exp = self._fix(context).split
|
2432
|
-
if self.subnormal?
|
2432
|
+
if self.subnormal?(context)
|
2433
2433
|
context.exception Subnormal
|
2434
2434
|
if exp > context.etiny
|
2435
2435
|
coeff = num_class.int_mult_radix_power(coeff, exp - context.etiny)
|
@@ -3916,10 +3916,11 @@ class Num < Numeric
|
|
3916
3916
|
exp_radix = output_radix
|
3917
3917
|
end
|
3918
3918
|
|
3919
|
-
|
3919
|
+
ds = ds.upcase if context.capitals
|
3920
|
+
|
3920
3921
|
if output_exp_radix == 2 && output_radix == 16
|
3921
3922
|
a_format = true
|
3922
|
-
digits_prefix =
|
3923
|
+
digits_prefix = (context.capitals ? '0X' : '0x')
|
3923
3924
|
exp_letter = (context.capitals ? 'P' : 'p')
|
3924
3925
|
show_exp = true
|
3925
3926
|
else
|
data/lib/flt/version.rb
CHANGED
data/test/test_basic.rb
CHANGED
@@ -450,4 +450,18 @@ class TestBasic < Test::Unit::TestCase
|
|
450
450
|
assert_equal "10000000", DecNum('0.1', :fixed).split[1].to_s
|
451
451
|
end
|
452
452
|
|
453
|
+
def test_normalizetion
|
454
|
+
DecNum.context.precision = 20
|
455
|
+
DecNum.context.emin = -1000
|
456
|
+
x = DecNum('5.10000000000E-502')
|
457
|
+
assert_equal [1, 510000000000, -513], x.split
|
458
|
+
context = DecNum.context(precision: 12, emin: -499)
|
459
|
+
assert_equal [1, 510000000, -510], x.normalize(context).split
|
460
|
+
assert_equal [1, 510000000, -510], context.normalize(x).split
|
461
|
+
DecNum.context = context
|
462
|
+
assert_equal [1, 510000000, -510], x.normalize(context).split
|
463
|
+
assert_equal [1, 510000000, -510], context.normalize(x).split
|
464
|
+
assert_equal [1, 510000000000, -513], x.split
|
465
|
+
end
|
466
|
+
|
453
467
|
end
|
data/test/test_hex_format.rb
CHANGED
@@ -32,10 +32,17 @@ class TestHexFormat< Test::Unit::TestCase
|
|
32
32
|
BinNum.context(BinNum::FloatContext) do
|
33
33
|
@hex_test_data.each do |number|
|
34
34
|
hex_upcase = "%A" % number
|
35
|
+
hex_downcase = "%a" % number
|
35
36
|
number = BinNum(number)
|
36
37
|
# text = number.to_s(:base => :hex_bin, :all_digits => false, :output_rounding => BinNum.context.rounding)
|
37
|
-
|
38
|
-
|
38
|
+
text_up = BinNum.context(:capitals => true){
|
39
|
+
number.to_s(:base => :hex_bin, :all_digits => false, :output_rounding => nil)
|
40
|
+
}
|
41
|
+
assert_equal hex_upcase, text_up.upcase, "Write #{hex_upcase} (number)"
|
42
|
+
text_down = BinNum.context(:capitals => false){
|
43
|
+
number.to_s(:base => :hex_bin, :all_digits => false, :output_rounding => nil)
|
44
|
+
}
|
45
|
+
assert_equal hex_upcase, text_down.upcase, "Write #{hex_upcase} (number)"
|
39
46
|
end
|
40
47
|
end
|
41
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Goizueta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|