Sha256: cee80db5fa87473e4c45acee91014807bbaf5ecb15eb81aed69cbbe059929af5

Contents?: true

Size: 868 Bytes

Versions: 9

Compression:

Stored size: 868 Bytes

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))

class TC_shifts_last_bits < Test::Unit::TestCase
  def setup
    @a = GMP::Z.new(100)  # 01100100
    @b =- @a              # 10011100
  end
  
  def test_shifts
    assert_equal(   3, @a >> 5, "GMP::Z should >> correctly.")  # 00000011
    assert_equal(-  4, @b >> 5, "GMP::Z should >> correctly.")  # 11111100
    assert_equal( 400, @a << 2, "GMP::Z should << correctly.")  # 0110010000
    assert_equal(-400, @b << 2, "GMP::Z should << correctly.")  # 1110010000
  end
  
  def test_last_bits
    #assert_equal( 5, @a.lastbits_pos(5), "GMP::Z should lastbits_pos correctly.")  #   100
    #assert_equal(28, @b.lastbits_pos(5), "GMP::Z should lastbits_pos correctly.")  # 11100
    #assert_equal(-4, @b.lastbits_sgn(5), "GMP::Z should lastbits_sgn correctly.")
    # a.tshr 5 ???
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gmp-0.6.47 test/tc_z_shifts_last_bits.rb
gmp-0.6.43 test/tc_z_shifts_last_bits.rb
gmp-0.6.41 test/tc_z_shifts_last_bits.rb
gmp-0.6.31 test/tc_z_shifts_last_bits.rb
gmp-0.6.19 test/tc_z_shifts_last_bits.rb
gmp-0.6.17 test/tc_z_shifts_last_bits.rb
gmp-0.6.13 test/tc_z_shifts_last_bits.rb
gmp-0.6.7 test/tc_z_shifts_last_bits.rb
gmp-0.5.47 test/tc_z_shifts_last_bits.rb