git.ucc.asn.au
/
ipdf
/
code.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rational<Arbint> now passes realops.test
[ipdf/code.git]
/
src
/
arbint.h
diff --git
a/src/arbint.h
b/src/arbint.h
index
0f047c9
..
06008e0
100644
(file)
--- a/
src/arbint.h
+++ b/
src/arbint.h
@@
-23,7
+23,7
@@
namespace IPDF
virtual ~Arbint() {}
Arbint(const Arbint & cpy);
virtual ~Arbint() {}
Arbint(const Arbint & cpy);
- int64_t AsDigit() const
+ int64_t AsDigit() const
{
int64_t digit = (m_digits.size() == 1) ? m_digits[0] : 0x7FFFFFFFFFFFFFFF;
return (m_sign) ? -digit : digit;
{
int64_t digit = (m_digits.size() == 1) ? m_digits[0] : 0x7FFFFFFFFFFFFFFF;
return (m_sign) ? -digit : digit;
@@
-60,6
+60,13
@@
namespace IPDF
a -= add;
return a;
}
a -= add;
return a;
}
+
+ inline Arbint operator-()
+ {
+ Arbint a(*this);
+ a.m_sign = !a.m_sign;
+ return a;
+ }
inline Arbint operator*(const Arbint & mul) const
{
inline Arbint operator*(const Arbint & mul) const
{
@@
-124,7
+131,17
@@
namespace IPDF
}
bool IsZero() const;
}
bool IsZero() const;
- //inline operator double() const {return double(AsDigit());}
+ inline operator double() const
+ {
+ double acc = 0;
+ for(int i = m_digits.size()-1; i >= 0; --i)
+ {
+ acc += (double)m_digits[i];
+ acc *= (double)UINT64_MAX + 1.0;
+ }
+ if (m_sign) acc *= -1;
+ return acc;
+ }
inline operator int64_t() const {return AsDigit();}
//inline operator int() const {return int(AsDigit());}
inline operator int64_t() const {return AsDigit();}
//inline operator int() const {return int(AsDigit());}
UCC
git Repository :: git.ucc.asn.au