flt 1.4.6 → 1.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f6269709d2755e8f6cc52aed9a2d2bbee4cbcf0
4
- data.tar.gz: 1e17d3367948b38a3d37bf011b76e0589000a8a0
3
+ metadata.gz: a82d3975aca56adcdeefe93da5fed92f8adb4159
4
+ data.tar.gz: 2155cf086a59dc59ce6f01e19b00b546c58a77e0
5
5
  SHA512:
6
- metadata.gz: e58ff28351ba6dbf89c2bd2c2b5acb8837e4a45237231a471bbc085bbbfe048557db87a94c49b63a5716a76f833419356c4519b1adb5f3b92cd6368b8948fa9a
7
- data.tar.gz: 0cb92e963d19b7937fe841fb7b83506d8ba4bec7a395636ae2d2bae20ee585144744692a9088f9cad5e7e0ac00722e64ffc33c2e246cde62c902a6186b3dea0e
6
+ metadata.gz: d1b9044b8b0deafd52eac4f3b481bbd360e9fd70ed7fb70f7489ed7744cf40fce81218275b402c7547d57d7fabc4bc2cde078ed5faebcb21a814be559edd7ed8
7
+ data.tar.gz: 07196b48dcb47e16a745f0488b2cddb8b60e91056de66d020a12bfb9e5cbd27a57c5f36b21b9a7f8cc69815caa04a8708c999df6cca70a5f337642c32000a0aa
@@ -1,4 +1,9 @@
1
- == 1.4.6 2015-04-07
1
+ == 1.4.7 2015-04-05
2
+
3
+ * Bugfix
4
+ - The normalize method used the default context
5
+
6
+ == 1.4.6 2015-03-07
2
7
 
3
8
  * Bugfix
4
9
  - BigDecimal.context.copy_sign returned a Float
@@ -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
- # TODO: this doesn't need to be so ugly...
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 = "0x"
3923
+ digits_prefix = (context.capitals ? '0X' : '0x')
3923
3924
  exp_letter = (context.capitals ? 'P' : 'p')
3924
3925
  show_exp = true
3925
3926
  else
@@ -1,3 +1,3 @@
1
1
  module Flt
2
- VERSION = "1.4.6"
2
+ VERSION = "1.4.7"
3
3
  end
@@ -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
@@ -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
- text = number.to_s(:base => :hex_bin, :all_digits => false, :output_rounding => nil)
38
- assert_equal hex_upcase, text.upcase, "Write #{hex_upcase} (number)"
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.6
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-03-07 00:00:00.000000000 Z
11
+ date: 2015-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler