68 typedef unsigned int word;
95 void resize_to(
int,
int = 0 );
99 word operator [] (
int )
const;
100 word& operator [] (
int );
102 half_word half_at(
int )
const;
103 half_word& half_at(
int );
105 half_word* half_addr(
int = 0 )
const;
109 static word* alloc( std::size_t );
110 static void free( word*, std::size_t );
112 static word* alloc_word( std::size_t size );
113 static void free_word( word* array, std::size_t size );
130 scfx_mant::alloc( std::size_t size )
132 #if defined( SC_BIG_ENDIAN ) 133 return alloc_word( size ) + ( size - 1 );
134 #elif defined( SC_LITTLE_ENDIAN ) 135 return alloc_word( size );
141 scfx_mant::free( word* mant, std::size_t size )
143 #if defined( SC_BIG_ENDIAN ) 144 free_word( mant - ( size - 1 ), size );
145 #elif defined( SC_LITTLE_ENDIAN ) 146 free_word( mant, size );
154 SC_ASSERT_( i >= 0 && i < m_size,
"mantissa index out of range" );
155 #if defined( SC_BIG_ENDIAN ) 157 #elif defined( SC_LITTLE_ENDIAN ) 166 SC_ASSERT_( i >= 0 && i < m_size,
"mantissa index out of range" );
167 #if defined( SC_BIG_ENDIAN ) 169 #elif defined( SC_LITTLE_ENDIAN ) 176 : m_array(0), m_size(size_)
178 m_array = alloc( size_ );
183 : m_array(0), m_size(rhs.m_size)
185 m_array = alloc( m_size );
186 for(
int i = 0; i < m_size; i ++ )
198 if( m_size != rhs.m_size )
200 free( m_array, m_size );
201 m_array = alloc( m_size = rhs.m_size );
204 for(
int i = 0; i < m_size; i ++ )
217 free( m_array, m_size );
225 for(
int i = 0; i < m_size; i ++ )
242 m_array = alloc( m_size = size );
246 word* p = alloc( size );
250 int end =
sc_min( size, m_size );
253 for(
int i = 0; i <
size; i ++ )
257 #if defined( SC_BIG_ENDIAN ) 259 #elif defined( SC_LITTLE_ENDIAN ) 265 #if defined( SC_BIG_ENDIAN ) 267 #elif defined( SC_LITTLE_ENDIAN ) 275 for(
int i = 0; i <
size; i ++ )
279 #if defined( SC_BIG_ENDIAN ) 280 p[-size+1+i] = m_array[-m_size+1+i];
281 #elif defined( SC_LITTLE_ENDIAN ) 282 p[size-1-i] = m_array[m_size-1-i];
287 #if defined( SC_BIG_ENDIAN ) 289 #elif defined( SC_LITTLE_ENDIAN ) 297 free( m_array, m_size );
307 SC_ASSERT_( ( i >> 1 ) >= 0 && ( i >> 1 ) < m_size,
308 "mantissa index out of range" );
309 #if defined( SC_BIG_ENDIAN ) 310 return reinterpret_cast<half_word*
>( m_array )[-i];
311 #elif defined( SC_LITTLE_ENDIAN ) 312 return reinterpret_cast<half_word*
>( m_array )[i];
320 SC_ASSERT_( ( i >> 1 ) >= 0 && ( i >> 1 ) < m_size,
321 "mantissa index out of range" );
322 #if defined( SC_BIG_ENDIAN ) 323 return reinterpret_cast<half_word*
>( m_array )[-i];
324 #elif defined( SC_LITTLE_ENDIAN ) 325 return reinterpret_cast<half_word*
>( m_array )[i];
333 SC_ASSERT_( i >= 0 && i < m_size,
"mantissa index out of range" );
334 #if defined( SC_BIG_ENDIAN ) 335 return reinterpret_cast<half_word*
>( m_array - i ) + 1;
336 #elif defined( SC_LITTLE_ENDIAN ) 337 return reinterpret_cast<half_word*
>( m_array + i );
350 for(
int i = 0; i <
size; i ++ )
352 target[i] = ~source[i];
365 for(
int i = 0; i < mant.
size(); i ++ )
409 void*
operator new( std::size_t sz ) { return ::operator
new( sz ); }
418 scfx_mant_ref::remove_it()
428 : m_mant( 0 ), m_not_const( false )
433 : m_mant( const_cast<
scfx_mant*>( &mant ) ), m_not_const( false )
438 : m_mant( mant ), m_not_const( true )
447 m_mant =
const_cast<scfx_mant*
>( &mant );
half_word half_at(int) const
const T sc_min(const T &a, const T &b)
void inc(scfx_mant &mant)
Mantissa reference class.
void complement(scfx_mant &target, const scfx_mant &source, int size)
Miscellaneous definitions that are needed by the headers.
half_word * half_addr(int=0) const
word operator[](int) const
void resize_to(int, int=0)
#define SC_ASSERT_(cnd, msg)
scfx_mant & operator=(const scfx_mant &)
scfx_mant_ref & operator=(const scfx_mant &)