fixed: TTMATH_DEBUG_LOG has generated different carry-flags in UInt<> (when TTMATH_NOASM was used)
fixed: some GCC warnings about uninitialized variables added: macro TTMATH_BIG_DEFAULT_CLEAR when defined the default constructor from Big<> clears its mantissa and exponent Big<1, 2> var; var.mantissa and var.exponent will be set to zero (but var has the NaN flag set too - it is not zero value, this is mainly for debug purposes) added: Big::SetZeroNan() this method sets NaN flag (Not a Number) also clears the mantissa and exponent (similarly as it would be a zero value) git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@309 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
a1c41c02db
commit
ae61b302a8
|
@ -1,4 +1,4 @@
|
||||||
Version 0.9.2 prerelease (2010.09.05):
|
Version 0.9.2 prerelease (2010.09.15):
|
||||||
* fixed: Big::Add() sometimes incorrectly rounded the last bit from its mantissa
|
* fixed: Big::Add() sometimes incorrectly rounded the last bit from its mantissa
|
||||||
* fixed: Big::BigAnd() Big::BigOr() Big::BigXor() should have set NaN
|
* fixed: Big::BigAnd() Big::BigOr() Big::BigXor() should have set NaN
|
||||||
when the argument was negative (they only returned 2)
|
when the argument was negative (they only returned 2)
|
||||||
|
@ -29,6 +29,11 @@ Version 0.9.2 prerelease (2010.09.05):
|
||||||
* added: void UInt::Swap(UInt<value_size> & ss2)
|
* added: void UInt::Swap(UInt<value_size> & ss2)
|
||||||
void Big::Swap(UInt<value_size> & ss2)
|
void Big::Swap(UInt<value_size> & ss2)
|
||||||
method for swapping this for an argument
|
method for swapping this for an argument
|
||||||
|
* added: macro TTMATH_BIG_DEFAULT_CLEAR
|
||||||
|
when defined the default constructor from Big<> clears its mantissa and exponent
|
||||||
|
Big<1, 2> var;
|
||||||
|
var.mantissa and var.exponent will be set to zero
|
||||||
|
(but var has the NaN flag set too - it is not zero value, this is mainly for debug purposes)
|
||||||
* changed: now asm version is available only on x86 and amd64
|
* changed: now asm version is available only on x86 and amd64
|
||||||
(and only for GCC and MS VC compilers)
|
(and only for GCC and MS VC compilers)
|
||||||
* removed: macro TTMATH_RELEASE
|
* removed: macro TTMATH_RELEASE
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2010, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -273,12 +273,16 @@ namespace ttmath
|
||||||
template<class ValueType>
|
template<class ValueType>
|
||||||
ValueType Log(const ValueType & x, const ValueType & base, ErrorCode * err = 0)
|
ValueType Log(const ValueType & x, const ValueType & base, ErrorCode * err = 0)
|
||||||
{
|
{
|
||||||
if( x.IsNan() || base.IsNan() )
|
if( x.IsNan() )
|
||||||
{
|
{
|
||||||
if( err )
|
if( err ) *err = err_improper_argument;
|
||||||
*err = err_improper_argument;
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
return ValueType(); // default NaN
|
if( base.IsNan() )
|
||||||
|
{
|
||||||
|
if( err ) *err = err_improper_argument;
|
||||||
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueType result;
|
ValueType result;
|
||||||
|
@ -523,7 +527,7 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return result; // NaN is set by default
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( err )
|
if( err )
|
||||||
|
@ -854,7 +858,7 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return result; // NaN is set by default
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( x.GreaterWithoutSignThan(one) )
|
if( x.GreaterWithoutSignThan(one) )
|
||||||
|
@ -1080,7 +1084,7 @@ namespace ttmath
|
||||||
bool change_sign = false;
|
bool change_sign = false;
|
||||||
|
|
||||||
if( x.IsNan() )
|
if( x.IsNan() )
|
||||||
return result; // NaN is set by default
|
return x;
|
||||||
|
|
||||||
// if x is negative we're using the formula:
|
// if x is negative we're using the formula:
|
||||||
// atan(-x) = -atan(x)
|
// atan(-x) = -atan(x)
|
||||||
|
@ -1548,7 +1552,7 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return result; // NaN is set by default
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = x;
|
result = x;
|
||||||
|
@ -1584,7 +1588,7 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return result; // NaN is set by default
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = 180;
|
result = 180;
|
||||||
|
@ -1629,7 +1633,9 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return delimiter ; // NaN is set by default
|
delimiter.SetZeroNan(); // not needed, only to get rid of GCC warning about an uninitialized variable
|
||||||
|
|
||||||
|
return delimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
multipler = 60;
|
multipler = 60;
|
||||||
|
@ -1683,7 +1689,7 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return result; // NaN is set by default
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = x;
|
result = x;
|
||||||
|
@ -1719,7 +1725,7 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return result; // NaN is set by default
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = 200;
|
result = 200;
|
||||||
|
@ -1751,7 +1757,7 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return result; // NaN is set by default
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = x;
|
result = x;
|
||||||
|
@ -1801,7 +1807,7 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return result; // NaN is set by default
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = x;
|
result = x;
|
||||||
|
@ -1842,7 +1848,9 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return ValueType(); // NaN is set by default
|
x.SetNan();
|
||||||
|
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint c = x.Sqrt();
|
uint c = x.Sqrt();
|
||||||
|
@ -2065,7 +2073,9 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return ValueType(); // NaN is set by default
|
x.SetNan();
|
||||||
|
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( RootCheckIndexSign(x, index, err) ) return x;
|
if( RootCheckIndexSign(x, index, err) ) return x;
|
||||||
|
@ -2154,7 +2164,9 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return ValueType(); // NaN is set by default
|
a.SetNan();
|
||||||
|
|
||||||
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint c = a.Mod(b);
|
uint c = a.Mod(b);
|
||||||
|
@ -2652,7 +2664,7 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return result; // NaN is set by default
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cgamma.history.Get(n, result, err_tmp) )
|
if( cgamma.history.Get(n, result, err_tmp) )
|
||||||
|
@ -2731,7 +2743,9 @@ namespace ttmath
|
||||||
if( err )
|
if( err )
|
||||||
*err = err_improper_argument;
|
*err = err_improper_argument;
|
||||||
|
|
||||||
return result; // NaN set by default
|
x.SetNan();
|
||||||
|
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
one.SetOne();
|
one.SetOne();
|
||||||
|
|
|
@ -294,6 +294,17 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
this method sets NaN flag (Not a Number)
|
||||||
|
also clears the mantissa and exponent (similarly as it would be a zero value)
|
||||||
|
*/
|
||||||
|
void SetZeroNan()
|
||||||
|
{
|
||||||
|
SetZero();
|
||||||
|
SetNan();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
this method swappes this for an argument
|
this method swappes this for an argument
|
||||||
*/
|
*/
|
||||||
|
@ -3001,17 +3012,26 @@ public:
|
||||||
/*!
|
/*!
|
||||||
a default constructor
|
a default constructor
|
||||||
|
|
||||||
we don't set any of the members to zero
|
by default we don't set any of the members to zero
|
||||||
only NaN flag is set
|
only NaN flag is set
|
||||||
|
|
||||||
|
if you want the mantissa and exponent to be set to zero
|
||||||
|
define TTMATH_BIG_DEFAULT_CLEAR macro
|
||||||
|
(useful for debug purposes)
|
||||||
*/
|
*/
|
||||||
Big()
|
Big()
|
||||||
{
|
{
|
||||||
info = TTMATH_BIG_NAN;
|
#ifdef TTMATH_BIG_DEFAULT_CLEAR
|
||||||
|
|
||||||
/*
|
SetZeroNan();
|
||||||
we're directly setting 'info' (instead of calling SetNan())
|
|
||||||
in order to get rid of a warning saying that 'info' is uninitialized
|
#else
|
||||||
*/
|
|
||||||
|
info = TTMATH_BIG_NAN;
|
||||||
|
// we're directly setting 'info' (instead of calling SetNan())
|
||||||
|
// in order to get rid of a warning saying that 'info' is uninitialized
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3034,7 +3054,7 @@ public:
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
a constructor for copying from another object of this class
|
a constructor for copying from another object of this class
|
||||||
|
|
|
@ -1375,8 +1375,9 @@ private:
|
||||||
TTMATH_ASSERT( z1_size <= first_size*3 )
|
TTMATH_ASSERT( z1_size <= first_size*3 )
|
||||||
|
|
||||||
for(i=z1_size ; i<first_size*3 ; ++i)
|
for(i=z1_size ; i<first_size*3 ; ++i)
|
||||||
|
{
|
||||||
TTMATH_ASSERT( z1.table[i] == 0 )
|
TTMATH_ASSERT( z1.table[i] == 0 )
|
||||||
;
|
}
|
||||||
|
|
||||||
c = AddVector(result+first_size, z1.table, result_size-first_size, z1_size, result+first_size);
|
c = AddVector(result+first_size, z1.table, result_size-first_size, z1_size, result+first_size);
|
||||||
TTMATH_ASSERT(c==0)
|
TTMATH_ASSERT(c==0)
|
||||||
|
@ -1389,6 +1390,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning (default : 4717)
|
#pragma warning (default : 4717)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2009, Tomasz Sowa
|
* Copyright (c) 2006-2010, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -480,6 +480,8 @@ namespace ttmath
|
||||||
c = new_c;
|
c = new_c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c = (c != 0)? 1 : 0;
|
||||||
|
|
||||||
TTMATH_LOGC("UInt::Rcr2_one", c)
|
TTMATH_LOGC("UInt::Rcr2_one", c)
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
@ -518,7 +520,7 @@ namespace ttmath
|
||||||
c = new_c;
|
c = new_c;
|
||||||
}
|
}
|
||||||
|
|
||||||
TTMATH_LOGC("UInt::Rcl2", c)
|
TTMATH_LOGC("UInt::Rcl2", (c & 1))
|
||||||
|
|
||||||
return (c & 1);
|
return (c & 1);
|
||||||
}
|
}
|
||||||
|
@ -557,9 +559,11 @@ namespace ttmath
|
||||||
c = new_c;
|
c = new_c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c = (c & TTMATH_UINT_HIGHEST_BIT) ? 1 : 0;
|
||||||
|
|
||||||
TTMATH_LOGC("UInt::Rcr2", c)
|
TTMATH_LOGC("UInt::Rcr2", c)
|
||||||
|
|
||||||
return (c & TTMATH_UINT_HIGHEST_BIT) ? 1 : 0;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue