diff options
author | Clifford Wolf <clifford@clifford.at> | 2013-02-27 09:32:19 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2013-02-27 09:32:19 +0100 |
commit | a321a5c412090d04dfaea4b4876c4901c42cfe44 (patch) | |
tree | b08d286e0aea76be9aab7a543df0b51e76b6ede4 /bigint/BigIntegerUtils.cc | |
parent | 4f0c2862a0d7e1ca247e0a4d54301c7f8cc92fd8 (diff) | |
download | yosys-a321a5c412090d04dfaea4b4876c4901c42cfe44.tar.gz yosys-a321a5c412090d04dfaea4b4876c4901c42cfe44.tar.bz2 yosys-a321a5c412090d04dfaea4b4876c4901c42cfe44.zip |
Moved stand-alone libs to libs/ directory and added libs/subcircuit
Diffstat (limited to 'bigint/BigIntegerUtils.cc')
-rw-r--r-- | bigint/BigIntegerUtils.cc | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/bigint/BigIntegerUtils.cc b/bigint/BigIntegerUtils.cc deleted file mode 100644 index 44073af65..000000000 --- a/bigint/BigIntegerUtils.cc +++ /dev/null @@ -1,50 +0,0 @@ -#include "BigIntegerUtils.hh" -#include "BigUnsignedInABase.hh" - -std::string bigUnsignedToString(const BigUnsigned &x) { - return std::string(BigUnsignedInABase(x, 10)); -} - -std::string bigIntegerToString(const BigInteger &x) { - return (x.getSign() == BigInteger::negative) - ? (std::string("-") + bigUnsignedToString(x.getMagnitude())) - : (bigUnsignedToString(x.getMagnitude())); -} - -BigUnsigned stringToBigUnsigned(const std::string &s) { - return BigUnsigned(BigUnsignedInABase(s, 10)); -} - -BigInteger stringToBigInteger(const std::string &s) { - // Recognize a sign followed by a BigUnsigned. - return (s[0] == '-') ? BigInteger(stringToBigUnsigned(s.substr(1, s.length() - 1)), BigInteger::negative) - : (s[0] == '+') ? BigInteger(stringToBigUnsigned(s.substr(1, s.length() - 1))) - : BigInteger(stringToBigUnsigned(s)); -} - -std::ostream &operator <<(std::ostream &os, const BigUnsigned &x) { - BigUnsignedInABase::Base base; - long osFlags = os.flags(); - if (osFlags & os.dec) - base = 10; - else if (osFlags & os.hex) { - base = 16; - if (osFlags & os.showbase) - os << "0x"; - } else if (osFlags & os.oct) { - base = 8; - if (osFlags & os.showbase) - os << '0'; - } else - throw "std::ostream << BigUnsigned: Could not determine the desired base from output-stream flags"; - std::string s = std::string(BigUnsignedInABase(x, base)); - os << s; - return os; -} - -std::ostream &operator <<(std::ostream &os, const BigInteger &x) { - if (x.getSign() == BigInteger::negative) - os << '-'; - os << x.getMagnitude(); - return os; -} |