Sha256: fb3b8071f9929458657bc58674eea3dcc04718db3318b9daff506ec70b5a9a9c
Contents?: true
Size: 1.88 KB
Versions: 9
Compression:
Stored size: 1.88 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__),'helper.rb')) class TestBaseDigits < Test::Unit::TestCase def test_number_of_digits_in_other_base assert_equal Float::DIG, Float.context.representable_digits(10) assert_equal Float::DECIMAL_DIG, Float.context.necessary_digits(10) if defined?(BinNum::FloatContext) assert_equal Float::DIG, BinNum::FloatContext.representable_digits(10) assert_equal Float::DECIMAL_DIG, BinNum::FloatContext.necessary_digits(10) end assert_equal 6, BinNum::IEEESingleContext.representable_digits(10) assert_equal 9, BinNum::IEEESingleContext.necessary_digits(10) assert_equal 15, BinNum::IEEEDoubleContext.representable_digits(10) assert_equal 17, BinNum::IEEEDoubleContext.necessary_digits(10) assert_equal 18, BinNum::IEEEExtendedContext.representable_digits(10) assert_equal 21, BinNum::IEEEExtendedContext.necessary_digits(10) [10,15,20,100].each do |precision| DecNum.context(:precision => precision) do assert_equal precision, DecNum.context.representable_digits(10) assert_equal precision, DecNum.context.necessary_digits(10) end BinNum.context(:precision => precision) do assert_equal precision, BinNum.context.representable_digits(2) assert_equal precision, BinNum.context.necessary_digits(2) end end DecNum.context(:exact => true) do assert_nil DecNum.context.representable_digits(10) assert_nil DecNum.context.necessary_digits(10) assert_nil DecNum.context.representable_digits(2) assert_nil DecNum.context.necessary_digits(2) end BinNum.context(:exact => true) do assert_nil BinNum.context.representable_digits(10) assert_nil BinNum.context.necessary_digits(10) assert_nil BinNum.context.representable_digits(2) assert_nil BinNum.context.necessary_digits(2) end end end
Version data entries
9 entries across 9 versions & 1 rubygems