fixed: there was a TTMATH_REREFENCE_ASSERT error in Big::PowUInt() caused by: start.Mul(start)

fixed:   Big::Add incorrectly rounded 'this' when both exponents were equal
         it caused that sometimes when adding a zero the result has changed
         this had impact among other things on FromString() method
         "0,8" had different binary representation from "0,80"
changed: renamed: Big::PowUInt(UInt<pow_size> pow) -> Big::Pow(UInt<pow_size> pow)
         it returns 2 when there is: 0^0
changed: renamed: Big::PowInt(Int<pow_size> pow) -> Big::Pow(Int<pow_size> pow)
         it returns 2 when there is: 0^0 or 0^(-something)
changed: renamed: Big::PowBUInt() -> PowUInt(), Big::PowBInt() -> Big::PowInt()
         they return 2 when the arguments are incorrect (like above)
changed: UInt::SetBitInWord(uint & value, uint bit) is taking the first argument by a reference now,
         the specific bit is set in the 'value' and the method returns the last state of the bit (zero or one)
added:   UInt::GetBit(uint bit_index) - returning the state of the specific bit
changed: UInt::SetBit(uint bit_index) - it's using TTMATH_ASSERT now
changed: Big::Mod2() - it's using mantissa.GetBit() now
added:   Big::operator=(double) and Big::Big(double)
added:   TTMATH_ASSERT somewhere in ttmathuint64.h
added:   UInt::Pow(UInt<value_size> pow) and Int::Pow(Int<value_size> pow)


git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@104 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2009-03-11 19:05:13 +00:00
parent 404727f3de
commit 978815f12d
8 changed files with 337 additions and 107 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2008, Tomasz Sowa
* Copyright (c) 2006-2009, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,7 +59,52 @@ void test_uint()
int main()
{
using namespace ttmath;
/*
Int<300> uu, oo;
uu = -2;
oo = 5;
uint ccc = uu.Pow(oo);
if( ccc )
std::cout << "carry: " << ccc << std::endl;
else
std::cout << uu << std::endl;
return 0;
*/
/*
UInt<2> w = 100;
w.GetBit(64);
std::cout << w << std::endl;
return 0;
*/
/*
uint q = 100;
uint last = UInt<3>::SetBitInWord(q, 3);
std::cout << "nowa wartosc: " << q << ", wczesniejszy bit: " << last << std::endl;
return 0;
*/
/*
Big<1, 3> a = -26;
Int<3> b = -8;
uint c = a.Pow(b);
if ( c )
std::cout << "carry: " << c << std::endl;
else
std::cout << a << std::endl;
return 0;
*/
test_uint();

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2008, Tomasz Sowa
* Copyright (c) 2006-2009, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2008, Tomasz Sowa
* Copyright (c) 2006-2009, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without