Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62942 - sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-06-14 14:21:26


Author: bbartman
Date: 2010-06-14 14:21:26 EDT (Mon, 14 Jun 2010)
New Revision: 62942
URL: http://svn.boost.org/trac/boost/changeset/62942

Log:
cleaning up header file
Text files modified:
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/twos_complement_testing.cpp | 84 ----------------------------------------
   1 files changed, 0 insertions(+), 84 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/twos_complement_testing.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/twos_complement_testing.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/twos_complement_testing.cpp 2010-06-14 14:21:26 EDT (Mon, 14 Jun 2010)
@@ -16,12 +16,9 @@
 // std includes.
 #include <cstddef>
 #include <stdexcept>
-#include <iostream>
 
-using namespace std;
 namespace boost { namespace details {
 
-
 template < typename Encoded_Type,
             std::size_t Width,
             typename Return_Type,
@@ -140,95 +137,14 @@
 
 
 using namespace boost;
-using namespace std;
 int main() {
     {
- char encoded_value = -2;
-
- cout << bool( (encoded_value & bits_mask<char,7>::value) >> bits_mask<char,7>::offset );
- cout << bool( (encoded_value & bits_mask<char,6>::value) >> bits_mask<char,6>::offset );
- cout << bool( (encoded_value & bits_mask<char,5>::value) >> bits_mask<char,5>::offset );
- cout << bool( (encoded_value & bits_mask<char,4>::value) >> bits_mask<char,4>::offset );
- cout << bool( (encoded_value & bits_mask<char,3>::value) >> bits_mask<char,3>::offset );
- cout << bool( (encoded_value & bits_mask<char,2>::value) >> bits_mask<char,2>::offset );
- cout << bool( (encoded_value & bits_mask<char,1>::value) >> bits_mask<char,1>::offset );
- cout << bool( (encoded_value & bits_mask<char,0>::value) >> bits_mask<char,0>::offset );
- cout << endl;
-
-
-
- // BOOST_ASSERT((storage == 0xc));
-
- // 1111 1110 == -2 in a char.
- // Return_Type(encoded_value & low_bits_mask<Return_Type, Width - 1>::value)
- // - Return_Type(encoded_value & bits_mask<Decoding_Type, Width>::value);
- const unsigned int Width = 4;
- typedef std::size_t Return_Type;
- typedef char Encoding_Type;
- Return_Type eval_1(encoded_value & low_bits_mask<Return_Type, Width - 1>::value );
- BOOST_ASSERT(( encoded_value == static_cast<char>(0xfe)));
- BOOST_ASSERT(( eval_1 == bits_mask<Return_Type, 1,2>::value ));
-
- // get the sign bit
- Return_Type eval_2(
- static_cast<
- make_unsigned<Encoding_Type>::type
- >(
- encoded_value & bits_mask<
- Encoding_Type,
- bit_width<Encoding_Type>::value - 1
- >::value
- ) >> (bit_width<Encoding_Type>::value - Width)
- );
- BOOST_ASSERT(( eval_2 == 0x8));
-
- // this is how to encode a type with two's complement.
- Return_Type eval_3 = static_cast<
- make_unsigned<Encoding_Type>::type
- >(
- encoded_value & low_bits_mask<Return_Type, Width - 1>::value
- )
- ^
- (static_cast<
- make_unsigned<Encoding_Type>::type
- >(
- encoded_value & bits_mask<
- Encoding_Type,
- bit_width<Encoding_Type>::value - 1
- >::value
- ) >> (bit_width<Encoding_Type>::value - Width));
-
- BOOST_ASSERT(( eval_3 == 0xe));
- }
-
- // decoding a type inside of a Return_Type
- {
- typedef char Return_Type;
- typedef std::size_t Decoding_From_Type;
- const std::size_t Width = 4;
-
- std::size_t storage = 0xe;
-
-
- // get sign bit.
- Return_Type eval_4 = static_cast<Return_Type>(storage & bits_mask<Decoding_From_Type,Width - 1>::value);
- BOOST_ASSERT(( eval_4 == 0x8 ));
-
- Return_Type eval_5 = static_cast<Return_Type>(storage & bits_mask<Decoding_From_Type,Width - 1>::value) << (bit_width<Return_Type>::value - Width);
- BOOST_ASSERT(( eval_5 == static_cast<Return_Type>(0x80)));
-
- // getting value bits
- Return_Type eval_6 = static_cast<Return_Type>(storage & low_bits_mask<Decoding_From_Type,Width-1>::value );
- BOOST_ASSERT(( eval_6 == bits_mask<Return_Type,1,2>::value));
- }
- {
         std::size_t storage = 0;
         char temp = -2;
         storage = twos_complement_encoding< char, 4, unsigned int >( temp );
         BOOST_ASSERT((storage == 0xe));
 
         temp = twos_complement_decoding< unsigned int, 4, char >( storage );
- cout << "Value of Temp == "<< (int)temp <<endl;
         BOOST_ASSERT((temp == -2));
     }
     return 0;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk