Sha256: a8c65c4bbefadd9e5cbf6940ab1867eabdfd5c2e80a2e1a88090f11b917ac1fe

Contents?: true

Size: 624 Bytes

Versions: 4

Compression:

Stored size: 624 Bytes

Contents

require File.expand_path(File.join(File.dirname(__FILE__),'helper.rb'))


class TestBinfloatConversion < Minitest::Test

  def setup
    initialize_context
  end

  def test_conversions
    float_emulation_context
    srand 12322
    [:half_even, :half_up, :half_down, :down, :up, :floor, :ceiling].each do |rounding|
      BinNum.context.rounding = rounding
      1000.times do
        x = random_float
        txt = BinNum(x).to_s
        y = BinNum(txt, :fixed).to_f
        assert_equal x, y, "FAIL #{Float.context.split(x).inspect} #{rounding} #{Float.context.split(y).inspect} #{x.class}"
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flt-1.5.4 test/test_binfloat_conversion.rb
flt-1.5.3 test/test_binfloat_conversion.rb
flt-1.5.2 test/test_binfloat_conversion.rb
flt-1.5.1 test/test_binfloat_conversion.rb