flt 1.4.3 → 1.4.4

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
  SHA1:
3
- metadata.gz: 6562084b49c2846a0b760e21a555950fa998f08a
4
- data.tar.gz: 1d6fe60c1612876ac435bf4f25fd17b2a5dc1c60
3
+ metadata.gz: b31b19298dc561379a1bb087187ba69da8d959ab
4
+ data.tar.gz: b26b4ff187ec92bd51198b274666babf5123c856
5
5
  SHA512:
6
- metadata.gz: b98b9821e7aa201c23b59fffa24326741925fca5487765fe759adb6a01528a08941626304eb4a4883d7005228887ef65e752bebb7af1fd96a7d8bdd0bb0e582e
7
- data.tar.gz: 95f117f1c48ae1b0264c0ab7aed6e299b3c3a8faaa0a21b98a54d40c905e3fa40db228deb650f846602a907fb83f369dd2cee759cd4b1a5876b50ff18f1a210c
6
+ metadata.gz: 561ae33a6932265a5f6e708405c485c1d684f42db179c8575f5949bf78a7d25316a1ca5da03de911cfe7f82f8ee3c6e359a9f68d74c4862c5319a7cb06fa18bc
7
+ data.tar.gz: c29f03d82d8c9513d11318ce2f66fbcac5507757acc12fa7b4c01b0e65734583a1f244566d18626662ff35d57a06ffee1e0ac4bae4363d95978ed1b70ce7fb5f
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.4.4 2015-03-03
2
+
3
+ * Bugfix
4
+ - Context#Num() didn't honor the context (only the radix)
5
+
1
6
  == 1.4.3 2014-11-02
2
7
 
3
8
  * New features
data/lib/flt/num.rb CHANGED
@@ -485,6 +485,12 @@ class Num < Numeric
485
485
 
486
486
  # Constructor for the associated numeric class
487
487
  def Num(*args)
488
+ context = { context: self }
489
+ if args.last.kind_of?(Hash)
490
+ args = args[0...-1] + [ context.merge(args.last) ]
491
+ else
492
+ args << context
493
+ end
488
494
  num_class.Num(*args)
489
495
  end
490
496
 
@@ -6,7 +6,7 @@ module Flt
6
6
  # (Robert G. Burger, R. Kent Dybvig)
7
7
  #
8
8
  # This algorithm formats arbitrary base floating point numbers as decimal
9
- # text literals. The floating-point (with fixed precision) is interpreted as an approximated
9
+ # text literals. The floating-point (with fixed precision) is interpreted as an approximate
10
10
  # value, representing any value in its 'rounding-range' (the interval where all values round
11
11
  # to the floating-point value, with the given precision and rounding mode).
12
12
  # An alternative approach which is not taken here would be to represent the exact floating-point
@@ -56,7 +56,7 @@ module Flt
56
56
 
57
57
  # A Formatted object is created to format floating point numbers given:
58
58
  # * The input base in which numbers to be formatted are defined
59
- # * The input minimum expeonent
59
+ # * The input minimum exponent
60
60
  # * The output base to which the input is converted.
61
61
  # * The :raise_on_repeat option, true by default specifies that when
62
62
  # an infinite sequence of repeating significant digits is found on the output
@@ -26,7 +26,7 @@ module Flt
26
26
  # (William D. Clinger)
27
27
  class Reader
28
28
 
29
- # There are two different reading approaches, selected by the :mode parameter:
29
+ # There are three different reading approaches, selected by the :mode parameter:
30
30
  # * :fixed (the destination context defines the resulting precision) input is rounded as specified
31
31
  # by the context; if the context precision is 'exact', the exact input value will be represented
32
32
  # in the destination base, which can lead to a Inexact exception (or a NaN result and an Inexact flag)
data/lib/flt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Flt
2
- VERSION = "1.4.3"
2
+ VERSION = "1.4.4"
3
3
  end
data/test/test_basic.rb CHANGED
@@ -441,4 +441,13 @@ class TestBasic < Test::Unit::TestCase
441
441
 
442
442
  end
443
443
 
444
+ def test_context_constructor
445
+ DecNum.context.precision = 8
446
+ DecNum.context.rounding = :half_even
447
+ context = DecNum.context[precision: 4]
448
+ assert_equal "1000", context.Num('0.1', :fixed).split[1].to_s
449
+ assert_equal "1000", context.Num('0.1', :fixed, :base => 10).split[1].to_s
450
+ assert_equal "10000000", DecNum('0.1', :fixed).split[1].to_s
451
+ end
452
+
444
453
  end
data/test/test_bin.rb CHANGED
@@ -175,6 +175,15 @@ class TestBin < Test::Unit::TestCase
175
175
 
176
176
  end
177
177
 
178
+ def test_context_constructor
179
+ BinNum.context.precision = 16
180
+ BinNum.context.rounding = :half_even
181
+ context = BinNum.context[precision: 8]
182
+ assert_equal "11001101", context.Num('0.1', :fixed).split[1].to_s(2)
183
+ assert_equal "11001101", context.Num('0.1', :fixed, :base => 10).split[1].to_s(2)
184
+ assert_equal "1100110011001101", BinNum('0.1', :fixed).split[1].to_s(2)
185
+ end
186
+
178
187
  def test_text_to_float_exact
179
188
  BinNum.context.exact = :quiet
180
189
  %w{
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.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Goizueta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-02 00:00:00.000000000 Z
11
+ date: 2015-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler