66 typedef unsigned int word;
107 static word* alloc( std::size_t );
108 static void free(
word*, std::size_t );
110 static word* alloc_word( std::size_t size );
111 static void free_word(
word* array, std::size_t size );
128 scfx_mant::alloc( std::size_t size )
130 #if defined( SC_BIG_ENDIAN )
131 return alloc_word( size ) + ( size - 1 );
132 #elif defined( SC_LITTLE_ENDIAN )
133 return alloc_word( size );
139 scfx_mant::free(
word* mant, std::size_t size )
141 #if defined( SC_BIG_ENDIAN )
142 free_word( mant - ( size - 1 ), size );
143 #elif defined( SC_LITTLE_ENDIAN )
144 free_word( mant, size );
152 SC_ASSERT_( i >= 0 && i < m_size,
"mantissa index out of range" );
153 #if defined( SC_BIG_ENDIAN )
155 #elif defined( SC_LITTLE_ENDIAN )
164 SC_ASSERT_( i >= 0 && i < m_size,
"mantissa index out of range" );
165 #if defined( SC_BIG_ENDIAN )
167 #elif defined( SC_LITTLE_ENDIAN )
174 : m_array(0), m_size(size)
176 m_array = alloc( size );
181 : m_array(0), m_size(rhs.m_size)
183 m_array = alloc( m_size );
184 for(
int i = 0; i < m_size; i ++ )
196 if( m_size != rhs.m_size )
198 free( m_array, m_size );
199 m_array = alloc( m_size = rhs.m_size );
202 for(
int i = 0; i < m_size; i ++ )
215 free( m_array, m_size );
223 for(
int i = 0; i < m_size; i ++ )
240 m_array = alloc( m_size = size );
244 word* p = alloc( size );
248 int end =
sc_min( size, m_size );
251 for(
int i = 0; i <
size; i ++ )
255 #if defined( SC_BIG_ENDIAN )
257 #elif defined( SC_LITTLE_ENDIAN )
263 #if defined( SC_BIG_ENDIAN )
265 #elif defined( SC_LITTLE_ENDIAN )
273 for(
int i = 0; i <
size; i ++ )
277 #if defined( SC_BIG_ENDIAN )
278 p[-size+1+i] = m_array[-m_size+1+i];
279 #elif defined( SC_LITTLE_ENDIAN )
280 p[size-1-i] = m_array[m_size-1-i];
285 #if defined( SC_BIG_ENDIAN )
287 #elif defined( SC_LITTLE_ENDIAN )
295 free( m_array, m_size );
305 SC_ASSERT_( ( i >> 1 ) >= 0 && ( i >> 1 ) < m_size,
306 "mantissa index out of range" );
307 #if defined( SC_BIG_ENDIAN )
308 return reinterpret_cast<half_word*
>( m_array )[-i];
309 #elif defined( SC_LITTLE_ENDIAN )
310 return reinterpret_cast<half_word*
>( m_array )[i];
318 SC_ASSERT_( ( i >> 1 ) >= 0 && ( i >> 1 ) < m_size,
319 "mantissa index out of range" );
320 #if defined( SC_BIG_ENDIAN )
321 return reinterpret_cast<half_word*
>( m_array )[-i];
322 #elif defined( SC_LITTLE_ENDIAN )
323 return reinterpret_cast<half_word*
>( m_array )[i];
331 SC_ASSERT_( i >= 0 && i < m_size,
"mantissa index out of range" );
332 #if defined( SC_BIG_ENDIAN )
333 return reinterpret_cast<half_word*
>( m_array - i ) + 1;
334 #elif defined( SC_LITTLE_ENDIAN )
335 return reinterpret_cast<half_word*
>( m_array + i );
348 for(
int i = 0; i < size; i ++ )
350 target[i] = ~source[i];
363 for(
int i = 0; i < mant.
size(); i ++ )
407 void*
operator new( std::size_t sz ) { return ::operator
new( sz ); }
416 scfx_mant_ref::remove_it()
426 : m_mant( 0 ), m_not_const( false )
431 : m_mant( const_cast<
scfx_mant*>( &mant ) ), m_not_const( false )
436 : m_mant( mant ), m_not_const( true )
445 m_mant =
const_cast<scfx_mant*
>( &mant );
word operator[](int) const
#define SC_ASSERT_(cnd, msg)
void resize_to(int, int=0)
const T sc_min(const T &a, const T &b)
half_word * half_addr(int=0) const
scfx_mant_ref & operator=(const scfx_mant &)
void complement(scfx_mant &target, const scfx_mant &source, int size)
half_word half_at(int) const
scfx_mant & operator=(const scfx_mant &)
void inc(scfx_mant &mant)