|
Boost-Commit : |
From: zeux_at_[hidden]
Date: 2007-06-10 05:34:47
Author: zeux
Date: 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
New Revision: 4519
URL: http://svn.boost.org/trac/boost/changeset/4519
Log:
Rewrote << and >> for iostreams, added handling of + sign in string->bigint, binary operators test, comparison operators test, unary operators test, stream input/output test
Added:
sandbox/SOC/2007/bigint/libs/bigint/test/comparison.cpp
sandbox/SOC/2007/bigint/libs/bigint/test/stream.cpp
sandbox/SOC/2007/bigint/libs/bigint/test/unary.cpp
Text files modified:
sandbox/SOC/2007/bigint/boost/bigint/bigint.hpp | 260 ++++++++++++++++++++++++++++++++++++++-
sandbox/SOC/2007/bigint/boost/bigint/bigint_gmp.hpp | 4
sandbox/SOC/2007/bigint/boost/bigint/bigint_util.hpp | 15 ++
sandbox/SOC/2007/bigint/libs/bigint/test/Jamfile.v2 | 3
sandbox/SOC/2007/bigint/libs/bigint/test/arithmetics.cpp | 112 ++++++++++++++++
sandbox/SOC/2007/bigint/libs/bigint/test/can_convert_to.cpp | 4
sandbox/SOC/2007/bigint/libs/bigint/test/number_conversion.cpp | 2
sandbox/SOC/2007/bigint/libs/bigint/test/string_conversion.cpp | 6
sandbox/SOC/2007/bigint/libs/bigint/todo.txt | 43 ++++--
9 files changed, 413 insertions(+), 36 deletions(-)
Modified: sandbox/SOC/2007/bigint/boost/bigint/bigint.hpp
==============================================================================
--- sandbox/SOC/2007/bigint/boost/bigint/bigint.hpp (original)
+++ sandbox/SOC/2007/bigint/boost/bigint/bigint.hpp 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
@@ -11,6 +11,7 @@
#define BOOST_BIGINT_BIGINT_HPP
#include <string>
+#include <algorithm>
#include <boost/cstdint.hpp>
@@ -389,19 +390,264 @@
template <typename T, typename Tr> friend std::basic_ostream<T, Tr>& operator<<(std::basic_ostream<T, Tr>& lhs, const bigint_base& rhs)
{
- int base = (lhs.flags() & std::ios_base::hex) ? 16 : (lhs.flags() & std::ios_base::oct) ? 8 : 10;
- return lhs << detail::bigint::to_string(rhs, base, T());
+ std::basic_ostream<T, Tr>::sentry ok(lhs);
+
+ if (ok)
+ {
+ try
+ {
+ std::ios_base::fmtflags flags = lhs.flags() ;
+ std::ios_base::fmtflags basefield = flags & std::ios_base::basefield;
+ std::ios_base::fmtflags uppercase = flags & std::ios_base::uppercase;
+ std::ios_base::fmtflags showpos = flags & std::ios_base::showpos;
+ std::ios_base::fmtflags showbase = flags & std::ios_base::showbase;
+
+ int base = (basefield == std::ios_base::hex) ? 16 : (basefield == std::ios_base::oct) ? 8 : 10;
+
+ std::basic_string<T> str = detail::bigint::to_string(rhs, base, T());
+
+ if (uppercase && base == 16) std::transform(str.begin(), str.end(), str.begin(), detail::bigint::toupper());
+
+ std::string::size_type pad_length = 0;
+
+ // str[0] is safe, to_string will never return empty string
+ if (showpos && str[0] != '-')
+ {
+ str.insert(str.begin(), '+');
+ pad_length = 1;
+ }
+ else pad_length = (str[0] == '-');
+
+ const std::numpunct<T>& punct = std::use_facet<std::numpunct<T> >(lhs.getloc());
+
+ std::string grouping = punct.grouping();
+
+ if (!grouping.empty())
+ {
+ std::basic_string<T> nstr;
+
+ std::basic_string<T>::reverse_iterator it = str.rbegin();
+ std::basic_string<T>::reverse_iterator end = str.rend();
+ if (pad_length > 0) --end; // skip sign
+
+ size_t group_id = 0;
+ size_t chars_to_go = str.size() - pad_length;
+
+ while (it != end)
+ {
+ char limit = group_id >= grouping.size() ? (grouping.empty() ? 0 : grouping[grouping.size() - 1]) : grouping[group_id];
+
+ if (!nstr.empty()) nstr += punct.thousands_sep();
+
+ if (limit <= 0)
+ {
+ nstr.append(it, end);
+ break;
+ }
+
+ size_t count = (std::min)(static_cast<size_t>(limit), chars_to_go);
+
+ nstr.append(it, it + count);
+
+ it += count;
+ chars_to_go -= count;
+
+ if (group_id < grouping.size()) ++group_id;
+ }
+
+ std::reverse(nstr.begin(), nstr.end());
+
+ str.replace(str.begin() + pad_length, str.end(), nstr.begin(), nstr.end());
+ }
+
+ if (showbase && (base == 16 || base == 8))
+ {
+ const T str_0X[] = {T('0'), T('X'), T()};
+ const T str_0x[] = {T('0'), T('x'), T()};
+ const T str_0[] = {T('0'), T()};
+
+ str.insert(pad_length, base == 16 ? (uppercase ? str_0X : str_0x) : str_0);
+ if (base == 16) pad_length += 2;
+ }
+
+ if (lhs.width() != 0)
+ {
+ std::streamsize width = lhs.width();
+ lhs.width(0);
+
+ if (width > 0 && static_cast<size_t>(width) > str.length())
+ {
+ std::ios_base::fmtflags adjustfield = flags & std::ios_base::adjustfield;
+
+ std::string::size_type pad_pos = 0; // pad before
+
+ if (adjustfield == std::ios_base::left) pad_pos = str.length();
+ else if (adjustfield == std::ios_base::internal) pad_pos = pad_length;
+
+ str.insert(pad_pos, width - str.length(), lhs.fill());
+ }
+ }
+
+ return lhs << str;
+ }
+ catch (...)
+ {
+ lhs.setstate(std::ios_base::badbit); // may throw
+ return lhs;
+ }
+ }
+ else return lhs;
}
template <typename T, typename Tr> friend std::basic_istream<T, Tr>& operator>>(std::basic_istream<T, Tr>& lhs, bigint_base& rhs)
{
- std::basic_string<T> result;
- lhs >> result;
+ std::basic_istream<T, Tr>::sentry ok(lhs);
+
+ if (ok)
+ {
+ try
+ {
+ std::ios_base::fmtflags flags = lhs.flags() ;
+ std::ios_base::fmtflags basefield = flags & std::ios_base::basefield;
+
+ int base = (basefield == std::ios_base::hex) ? 16 : (basefield == std::ios_base::oct) ? 8 : 10;
+
+ int sign = 1;
+
+ std::basic_string<T> str;
+
+ if (flags & std::ios_base::skipws)
+ {
+ // skip whitespaces
+ while (lhs.peek() != Tr::eof() && detail::bigint::isspace(static_cast<T>(lhs.peek())))
+ lhs.get();
+ }
+
+ if (lhs.peek() == T('-') || lhs.peek() == T('+'))
+ {
+ sign = lhs.get() == T('-') ? -1 : 1;
+ }
+
+ T char_table[] = {T('0'), T('1'), T('2'), T('3'), T('4'), T('5'), T('6'), T('7'), T('8'), T('9'),
+ T('a'), T('b'), T('c'), T('d'), T('e'), T('f'), T('A'), T('B'), T('C'), T('D'),
+ T('E'), T('F'), T()};
+
+ size_t char_table_size = base == 16 ? sizeof(char_table) / sizeof(char_table[0]) : base;
+
+ if (lhs.peek() == T('0'))
+ {
+ lhs.get();
+
+ if (lhs.peek() == T('x') || lhs.peek() == T('X')) // 0x 0X
+ lhs.get(); // skip
+ else
+ {
+ while (lhs.peek() == T('0')) lhs.get(); // skip zeroes
+
+ if (Tr::find(char_table, char_table_size, lhs.peek()) == 0) // next symbol is non-digit, we needed that 0
+ str += T('0');
+ }
+ }
+
+ const std::numpunct<T>& punct = std::use_facet<std::numpunct<T> >(lhs.getloc());
+
+ Tr::int_type ch;
+
+ while ((ch = lhs.peek()) != Tr::eof())
+ {
+ // do we allow this kind of character?
+ if (ch == punct.thousands_sep() || Tr::find(char_table, char_table_size, ch) != 0)
+ {
+ str += lhs.get();
+ }
+ else
+ {
+ // have we read any valid data?
+ if (str.empty())
+ {
+ // no.
+ lhs.setstate(std::ios_base::badbit); // may throw
+ return lhs;
+ }
+
+ break;
+ }
+ }
+
+ std::string grouping = punct.grouping();
- int base = (lhs.flags() & std::ios_base::hex) ? 16 : (lhs.flags() & std::ios_base::oct) ? 8 : 10;
- rhs = bigint_base(result, base);
+ if (!grouping.empty())
+ {
+ std::basic_string<T>::reverse_iterator it = str.rbegin();
+ std::basic_string<T>::reverse_iterator end = str.rend();
- return lhs;
+ size_t group_id = 0;
+ size_t chars_to_go = str.size();
+
+ while (it != end)
+ {
+ char limit = group_id >= grouping.size() ? (grouping.empty() ? 0 : grouping[grouping.size() - 1]) : grouping[group_id];
+
+ std::basic_string<T>::reverse_iterator sep_it = std::find(it, end, punct.thousands_sep());
+
+ if (limit <= 0) // unlimited sequence of digits
+ {
+ if (sep_it != str.rend()) // there's another separator, error
+ {
+ lhs.setstate(std::ios_base::badbit); // may throw
+ return lhs;
+ }
+
+ break;
+ }
+
+ // limited sequence of digits
+
+ // we're not at the end
+ if (sep_it != str.rend())
+ {
+ // digit sequence sizes do not match
+ if (limit != std::distance(it, sep_it))
+ {
+ lhs.setstate(std::ios_base::badbit); // may throw
+ return lhs;
+ }
+ else
+ {
+ it = sep_it;
+ ++it;
+ }
+ }
+ else if (limit < std::distance(it, sep_it)) // we're at the end, and our sequence size is larger
+ {
+ lhs.setstate(std::ios_base::badbit); // may throw
+ return lhs;
+ }
+ else
+ {
+ // we're at the end
+ break;
+ }
+
+ if (group_id < grouping.size()) ++group_id;
+ }
+
+ // remove all separators, we don't need them
+ str.erase(std::remove(str.begin(), str.end(), punct.thousands_sep()), str.end());
+ }
+
+ rhs = bigint_base(str, base);
+ if (sign == -1) rhs.impl.negate(rhs.impl);
+
+ return lhs;
+ }
+ catch (...)
+ {
+ lhs.setstate(std::ios_base::badbit); // may throw
+ return lhs;
+ }
+ }
+ else return lhs;
}
};
Modified: sandbox/SOC/2007/bigint/boost/bigint/bigint_gmp.hpp
==============================================================================
--- sandbox/SOC/2007/bigint/boost/bigint/bigint_gmp.hpp (original)
+++ sandbox/SOC/2007/bigint/boost/bigint/bigint_gmp.hpp 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
@@ -106,6 +106,10 @@
sign = -1;
++str;
}
+ else if (*str == Ch('+'))
+ {
+ ++str;
+ }
static const unsigned char digit_value_tab[] =
{
Modified: sandbox/SOC/2007/bigint/boost/bigint/bigint_util.hpp
==============================================================================
--- sandbox/SOC/2007/bigint/boost/bigint/bigint_util.hpp (original)
+++ sandbox/SOC/2007/bigint/boost/bigint/bigint_util.hpp 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
@@ -12,6 +12,19 @@
namespace boost { namespace detail { namespace bigint {
+ struct toupper
+ {
+ char operator()(char ch) const
+ {
+ return ::toupper(ch);
+ }
+
+ wchar_t operator()(wchar_t ch) const
+ {
+ return ::towupper(ch);
+ }
+ };
+
inline bool isspace(char ch)
{
return ::isspace(ch) != 0;
@@ -21,7 +34,7 @@
{
return ::iswspace(ch) != 0;
}
-
+
inline size_t length(const char* str)
{
return ::strlen(str);
Modified: sandbox/SOC/2007/bigint/libs/bigint/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/bigint/libs/bigint/test/Jamfile.v2 (original)
+++ sandbox/SOC/2007/bigint/libs/bigint/test/Jamfile.v2 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
@@ -13,6 +13,9 @@
[ run string_conversion.cpp ]
[ run can_convert_to.cpp ]
[ run arithmetics.cpp ]
+ [ run comparison.cpp ]
+ [ run unary.cpp ]
+ [ run stream.cpp ]
;
}
Modified: sandbox/SOC/2007/bigint/libs/bigint/test/arithmetics.cpp
==============================================================================
--- sandbox/SOC/2007/bigint/libs/bigint/test/arithmetics.cpp (original)
+++ sandbox/SOC/2007/bigint/libs/bigint/test/arithmetics.cpp 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
@@ -13,10 +13,6 @@
#include <boost/bigint/bigint.hpp>
-#include <sstream>
-
-#include <iostream>
-
#pragma comment(lib, "libgmp-3.lib")
// This macro is not quite good, but - it's ok for our needs
@@ -137,6 +133,92 @@
{"2394023940394034", '%', "9", "5"},
{"2394023940394034", '%', "8", "2"},
{"2394023940394034", '%', "234890234034", "22675119506"},
+
+ // bit-and
+
+ // zero
+ {"0", '&', "3894823948293489234", "0"},
+ // positive vs positive
+ {"4", '&', "6", "4"},
+ {"2855076450534541305", '&', "13904", "1616"},
+ {"9095384758374758347534", '&', "239892384938492384080", "239879959323226100480"},
+ // -1
+ {"23904823948293482934", '&', "-1", "23904823948293482934"},
+ // positive vs negative
+ {"13", '&', "-3", "13"}, // 1101 & 1...101
+ {"15", '&', "-3", "13"}, // 1111 & 1...101
+ // negative vs negative
+ {"-4", '&', "-6", "-8"}, // 1...1100 & 1...1010
+ {"-2855076450534541305", '&', "-13904", "-2855076450534553600"},
+ {"-9095384758374758347534", '&', "-239892384938492384080", "-9095397183990024631120"},
+
+ // bit-or
+
+ // zero
+ {"0", '|', "3894823948293489234", "3894823948293489234"},
+ // positive vs positive
+ {"4", '|', "6", "6"},
+ {"2855076450534541305", '|', "13904", "2855076450534553593"},
+ {"9095384758374758347534", '|', "239892384938492384080", "9095397183990024631134"},
+ // -1
+ {"23904823948293482934", '|', "-1", "-1"},
+ // positive vs negative
+ {"13", '|', "-3", "-3"}, // 1101 | 1...101
+ {"15", '|', "-3", "-1"}, // 1111 | 1...101
+ // negative vs negative
+ {"-4", '|', "-6", "-2"},
+ {"-2855076450534541305", '|', "-13904", "-1609"},
+ {"-9095384758374758347534", '|', "-239892384938492384080", "-239879959323226100494"},
+
+ // bit-xor
+
+ // zero
+ {"0", '^', "3894823948293489234", "3894823948293489234"},
+ // positive vs positive
+ {"4", '^', "6", "2"},
+ {"2855076450534541305", '^', "13904", "2855076450534551977"},
+ {"9095384758374758347534", '^', "239892384938492384080", "8855517224666798530654"},
+ // -1
+ {"23904823948293482934", '^', "-1", "-23904823948293482935"},
+ // positive vs negative
+ {"13", '^', "-3", "-16"}, // 1101 ^ 1...1101
+ {"15", '^', "-3", "-14"}, // 1111 ^ 1...1101
+ // negative vs negative
+ {"-4", '^', "-6", "6"},
+ {"-2855076450534541305", '^', "-13904", "2855076450534551991"},
+ {"-9095384758374758347534", '^', "-239892384938492384080", "8855517224666798530626"},
+
+ // left shift
+
+ // zero
+ {"0", '<', "2389042304", "0"},
+ {"1238923498294", '<', "0", "1238923498294"},
+ {"-1238923498294", '<', "0", "-1238923498294"},
+ // positive numbers - a << n is equal to a * 2^n
+ {"1", '<', "10", "1024"},
+ {"13498", '<', "15", "442302464"},
+ {"94172371", '<', "65", "3474347253302854482051203072"},
+ // negative numbers - a << n is equal to a * 2^n
+ {"-1", '<', "10", "-1024"},
+ {"-13498", '<', "15", "-442302464"},
+ {"-94172371", '<', "65", "-3474347253302854482051203072"},
+
+ // right shift
+
+ // zero
+ {"0", '>', "2389042304", "0"},
+ {"1238923498294", '>', "0", "1238923498294"},
+ {"-1238923498294", '>', "0", "-1238923498294"},
+ // positive numbers - a >> n is equal to floor(a / 2^n)
+ {"1", '>', "10", "0"},
+ {"11248972814738247", '>', "15", "343291406699"},
+ {"3474347253302854482051234871283", '>', "65", "94172371000"},
+ // negative numbers - a >> n is equal to floor(a / 2^n) (rounding to -infinity!)
+ {"-1024", '>', "10", "-1"},
+ {"-442302464", '>', "15", "-13498"},
+ {"-3474347253302854482051203072", '>', "65", "-94172371"},
+ {"-33", '>', "4", "-3"},
+ {"-23894283948234823948324123", '>', "71", "-10120"}
};
for (size_t i = 0; i < ARRAY_SIZE(entries); ++i)
@@ -165,6 +247,22 @@
} \
} break
+#define GEN_SOP(op, chop) case chop: \
+ { \
+ if (b.can_convert_to<boost::uint64_t>()) \
+ { \
+ boost::uint64_t ub = b.to_number<boost::uint64_t>(); \
+ \
+ BOOST_CHECK_EQUAL(a op ub, c); \
+ \
+ number d = a; \
+ d op##= ub; \
+ \
+ BOOST_CHECK_EQUAL(d, c); \
+ } \
+ else BOOST_CHECK(false); \
+ } break
+
switch (e.op)
{
GEN_OP(+, '+');
@@ -172,8 +270,14 @@
GEN_OP(*, '*');
GEN_OP(/, '/');
GEN_OP(%, '%');
+ GEN_OP(&, '&');
+ GEN_OP(|, '|');
+ GEN_OP(^, '^');
+ GEN_SOP(<<, '<');
+ GEN_SOP(>>, '>');
}
+#undef GEN_SOP
#undef GEN_OP
}
}
Modified: sandbox/SOC/2007/bigint/libs/bigint/test/can_convert_to.cpp
==============================================================================
--- sandbox/SOC/2007/bigint/libs/bigint/test/can_convert_to.cpp (original)
+++ sandbox/SOC/2007/bigint/libs/bigint/test/can_convert_to.cpp 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
@@ -13,10 +13,6 @@
#include <boost/bigint/bigint.hpp>
-#include <sstream>
-
-#include <iostream>
-
#pragma comment(lib, "libgmp-3.lib")
template <typename I> void test()
Added: sandbox/SOC/2007/bigint/libs/bigint/test/comparison.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/bigint/libs/bigint/test/comparison.cpp 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
@@ -0,0 +1,300 @@
+/* Boost comparison.cpp test file
+ *
+ * Copyright 2007 Arseny Kapoulkine
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or
+ * copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#define BOOST_DISABLE_WIN32
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+#include <boost/bigint/bigint.hpp>
+
+#pragma comment(lib, "libgmp-3.lib")
+
+// This macro is not quite good, but - it's ok for our needs
+#define ARRAY_SIZE(array) sizeof(array) / sizeof(array[0])
+
+template <typename I> void test()
+{
+ typedef boost::bigint_base<I> number;
+
+ struct test_entry
+ {
+ const char* lhs;
+ const char* op;
+ const char* rhs;
+ bool result;
+ };
+
+ // Some tests are a bit redundant, because "test that comparison operations are sane" was implemented too late
+ test_entry entries[] =
+ {
+ // ordering
+
+ // 0 and -0
+ {"0", "<", "-0", false},
+ {"0", "<=", "-0", true},
+ {"0", ">", "-0", false},
+ {"0", ">=", "-0", true},
+
+ // 0 and other numbers
+ {"0", ">", "-3", true},
+ {"0", ">=", "-3", true},
+ {"0", "<", "-3", false},
+ {"0", "<=", "-3", false},
+
+ {"0", ">", "-234892349823943243", true},
+ {"0", ">=", "-234892349823943243", true},
+ {"0", "<", "-234892349823943243", false},
+ {"0", "<=", "-234892349823943243", false},
+
+ {"0", ">", "5", false},
+ {"0", ">=", "5", false},
+ {"0", "<", "5", true},
+ {"0", "<=", "5", true},
+
+ {"0", ">", "534892349823943243", false},
+ {"0", ">=", "534892349823943243", false},
+ {"0", "<", "534892349823943243", true},
+ {"0", "<=", "534892349823943243", true},
+
+ // equal small numbers
+ {"3", "<", "3", false},
+ {"3", "<=", "3", true},
+ {"3", ">", "3", false},
+ {"3", ">=", "3", true},
+
+ {"-3", "<", "-3", false},
+ {"-3", "<=", "-3", true},
+ {"-3", ">", "-3", false},
+ {"-3", ">=", "-3", true},
+
+ // equal big numbers
+ {"32398042834928394234", "<", "32398042834928394234", false},
+ {"32398042834928394234", "<=", "32398042834928394234", true},
+ {"32398042834928394234", ">", "32398042834928394234", false},
+ {"32398042834928394234", ">=", "32398042834928394234", true},
+
+ {"-32398042834928394234", "<", "-32398042834928394234", false},
+ {"-32398042834928394234", "<=", "-32398042834928394234", true},
+ {"-32398042834928394234", ">", "-32398042834928394234", false},
+ {"-32398042834928394234", ">=", "-32398042834928394234", true},
+
+ // small numbers of the same sign
+ {"15", "<", "17", true},
+ {"15", "<=", "17", true},
+ {"15", ">", "17", false},
+ {"15", ">=", "17", false},
+
+ {"20", "<", "17", false},
+ {"20", "<=", "17", false},
+ {"20", ">", "17", true},
+ {"20", ">=", "17", true},
+
+ {"-15", "<", "-17", false},
+ {"-15", "<=", "-17", false},
+ {"-15", ">", "-17", true},
+ {"-15", ">=", "-17", true},
+
+ {"-20", "<", "-17", true},
+ {"-20", "<=", "-17", true},
+ {"-20", ">", "-17", false},
+ {"-20", ">=", "-17", false},
+
+ // big numbers of the same sign, big difference
+ {"2387238472384", "<", "5387238472384", true},
+ {"2387238472384", "<=", "5387238472384", true},
+ {"2387238472384", ">", "5387238472384", false},
+ {"2387238472384", ">=", "5387238472384", false},
+
+ {"9387238472384", "<", "5387238472384", false},
+ {"9387238472384", "<=", "5387238472384", false},
+ {"9387238472384", ">", "5387238472384", true},
+ {"9387238472384", ">=", "5387238472384", true},
+
+ {"-2387238472384", "<", "-5387238472384", false},
+ {"-2387238472384", "<=", "-5387238472384", false},
+ {"-2387238472384", ">", "-5387238472384", true},
+ {"-2387238472384", ">=", "-5387238472384", true},
+
+ {"-9387238472384", "<", "-5387238472384", true},
+ {"-9387238472384", "<=", "-5387238472384", true},
+ {"-9387238472384", ">", "-5387238472384", false},
+ {"-9387238472384", ">=", "-5387238472384", false},
+
+ // big numbers of the same sign, small difference
+ {"348923849238492384", "<", "348923849238492385", true},
+ {"348923849238492384", "<=", "348923849238492385", true},
+ {"348923849238492384", ">", "348923849238492385", false},
+ {"348923849238492384", ">=", "348923849238492385", false},
+
+ {"348923849238492386", "<", "348923849238492385", false},
+ {"348923849238492386", "<=", "348923849238492385", false},
+ {"348923849238492386", ">", "348923849238492385", true},
+ {"348923849238492386", ">=", "348923849238492385", true},
+
+ {"-348923849238492384", "<", "-348923849238492385", false},
+ {"-348923849238492384", "<=", "-348923849238492385", false},
+ {"-348923849238492384", ">", "-348923849238492385", true},
+ {"-348923849238492384", ">=", "-348923849238492385", true},
+
+ {"-348923849238492386", "<", "-348923849238492385", true},
+ {"-348923849238492386", "<=", "-348923849238492385", true},
+ {"-348923849238492386", ">", "-348923849238492385", false},
+ {"-348923849238492386", ">=", "-348923849238492385", false},
+
+ // small numbers of different sign
+ {"34", "<", "-5", false},
+ {"34", "<=", "-5", false},
+ {"34", ">", "-5", true},
+ {"34", ">=", "-5", true},
+
+ {"-34", "<", "5", true},
+ {"-34", "<=", "5", true},
+ {"-34", ">", "5", false},
+ {"-34", ">=", "5", false},
+
+ // big numbers of different sign
+ {"12834823948239423489", "<", "-523849234", false},
+ {"12834823948239423489", "<=", "-523849234", false},
+ {"12834823948239423489", ">", "-523849234", true},
+ {"12834823948239423489", ">=", "-523849234", true},
+
+ {"-12834823948239423489", "<", "523849234", true},
+ {"-12834823948239423489", "<=", "523849234", true},
+ {"-12834823948239423489", ">", "523849234", false},
+ {"-12834823948239423489", ">=", "523849234", false},
+
+ // equality
+
+ // 0 and -0
+ {"0", "==", "-0", true},
+ {"0", "!=", "-0", false},
+
+ // 0 and other numbers
+ {"0", "==", "4", false},
+ {"0", "!=", "4", true},
+ {"0", "==", "-4", false},
+ {"0", "!=", "-4", true},
+
+ {"0", "==", "24389283492834928349", false},
+ {"0", "!=", "24389283492834928349", true},
+ {"0", "==", "-24389283492834928349", false},
+ {"0", "!=", "-24389283492834928349", true},
+
+ // small numbers
+ {"4", "==", "4", true},
+ {"4", "!=", "4", false},
+ {"4", "==", "-4", false},
+ {"4", "!=", "-4", true},
+
+ {"4", "==", "8", false},
+ {"4", "!=", "8", true},
+ {"4", "==", "-8", false},
+ {"4", "!=", "-8", true},
+
+ {"8", "==", "4", false},
+ {"8", "!=", "4", true},
+ {"8", "==", "-4", false},
+ {"8", "!=", "-4", true},
+
+ // big numbers vs small numbers
+ {"249839482934823944", "==", "8", false},
+ {"249839482934823944", "!=", "8", true},
+ {"249839482934823944", "==", "-8", false},
+ {"249839482934823944", "!=", "-8", true},
+
+ {"8", "==", "249839482934823944", false},
+ {"8", "!=", "249839482934823944", true},
+ {"8", "==", "-249839482934823944", false},
+ {"8", "!=", "-249839482934823944", true},
+
+ // big numbers
+ {"12349812340981230494", "==", "12349812340981230494", true},
+ {"12349812340981230494", "!=", "12349812340981230494", false},
+ {"12349812340981230494", "==", "-12349812340981230494", false},
+ {"12349812340981230494", "!=", "-12349812340981230494", true},
+
+ {"20349230492349234344", "==", "359685968958695434088", false},
+ {"20349230492349234344", "!=", "359685968958695434088", true},
+ {"20349230492349234344", "==", "-359685968958695434088", false},
+ {"20349230492349234344", "!=", "-359685968958695434088", true},
+
+ {"359685968958695434088", "==", "20349230492349234344", false},
+ {"359685968958695434088", "!=", "20349230492349234344", true},
+ {"359685968958695434088", "==", "-20349230492349234344", false},
+ {"359685968958695434088", "!=", "-20349230492349234344", true}
+ };
+
+ for (size_t i = 0; i < ARRAY_SIZE(entries); ++i)
+ {
+ const test_entry& e = entries[i];
+
+ number a(e.lhs), b(e.rhs);
+ bool c = e.result;
+
+ // test that comparison operations are sane
+
+ // <
+ BOOST_CHECK_EQUAL(a < b, !(a >= b));
+ if (a < b) BOOST_CHECK(a <= b);
+
+ // <=
+ BOOST_CHECK_EQUAL(a <= b, !(a > b));
+ BOOST_CHECK_EQUAL(a <= b, a < b || a == b);
+
+ // >
+ BOOST_CHECK_EQUAL(a > b, !(a <= b));
+ if (a > b) BOOST_CHECK(a >= b);
+
+ // >=
+ BOOST_CHECK_EQUAL(a >= b, !(a < b));
+ BOOST_CHECK_EQUAL(a >= b, a > b || a == b);
+
+ // ==
+ BOOST_CHECK_EQUAL(a == b, !(a != b));
+ BOOST_CHECK_EQUAL(a == b, a <= b && a >= b);
+
+ // !=
+ BOOST_CHECK_EQUAL(a != b, !(a == b));
+ BOOST_CHECK_EQUAL(a != b, a < b || a > b);
+
+#define GEN_OP(_op, sop) else if (!strcmp(e.op, sop)) \
+ { \
+ BOOST_CHECK_EQUAL(a _op b, c); \
+ \
+ if (a.can_convert_to<boost::int64_t>()) \
+ { \
+ BOOST_CHECK_EQUAL(a.to_number<boost::int64_t>() _op b, c); \
+ } \
+ \
+ if (b.can_convert_to<boost::int64_t>()) \
+ { \
+ BOOST_CHECK_EQUAL(a _op b.to_number<boost::int64_t>(), c); \
+ } \
+ }
+
+ // comparison tests
+ if (false) ;
+ GEN_OP(<, "<")
+ GEN_OP(<=, "<=")
+ GEN_OP(>, ">")
+ GEN_OP(>=, ">=")
+ GEN_OP(==, "==")
+ GEN_OP(!=, "!=")
+ else BOOST_CHECK(false);
+
+#undef GEN_OP
+ }
+}
+
+int test_main(int argc, char* argv[])
+{
+ test<boost::detail::bigint_gmp_implementation>();
+
+ return 0;
+}
Modified: sandbox/SOC/2007/bigint/libs/bigint/test/number_conversion.cpp
==============================================================================
--- sandbox/SOC/2007/bigint/libs/bigint/test/number_conversion.cpp (original)
+++ sandbox/SOC/2007/bigint/libs/bigint/test/number_conversion.cpp 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
@@ -15,8 +15,6 @@
#include <sstream>
-#include <iostream>
-
#pragma comment(lib, "libgmp-3.lib")
// This macro is not quite good, but - it's ok for our needs
Added: sandbox/SOC/2007/bigint/libs/bigint/test/stream.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/bigint/libs/bigint/test/stream.cpp 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
@@ -0,0 +1,256 @@
+/* Boost unary.cpp test file
+ *
+ * Copyright 2007 Arseny Kapoulkine
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or
+ * copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#define BOOST_DISABLE_WIN32
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+#include <boost/bigint/bigint.hpp>
+
+#include <string>
+#include <sstream>
+
+#pragma comment(lib, "libgmp-3.lib")
+
+template <typename T, typename Tr> std::basic_ios<T, Tr>& setfillch(std::basic_ios<T, Tr>& s)
+{
+ s.fill('_');
+ return s;
+}
+
+template <typename T, typename Tr> std::basic_ios<T, Tr>& setusanumlocale(std::basic_ios<T, Tr>& s)
+{
+ std::locale c_loc;
+ std::locale sys(c_loc, "LC_NUMERIC=ENG_USA;", std::locale::numeric);
+
+ s.imbue(sys);
+
+ return s;
+}
+
+template <typename I> void test()
+{
+ typedef boost::bigint_base<I> number;
+
+#define CHECK_OSS(expr, result) do \
+ { \
+ std::ostringstream oss; oss << expr; \
+ BOOST_CHECK_EQUAL(oss.str(), result); \
+ BOOST_CHECK(oss.good()); \
+ \
+ std::wostringstream woss; woss << expr; \
+ const char* r = result; \
+ BOOST_CHECK(woss.str() == std::wstring(r, r + strlen(r))); \
+ BOOST_CHECK(woss.good()); \
+ } \
+ while (0)
+
+#define CHECK_ISS_MOD_STATE(input, mod, result, state) do \
+ { \
+ number a(7); \
+ std::istringstream iss(input); iss >> mod >> a; \
+ BOOST_CHECK_EQUAL(a, number(result)); \
+ if (!state) BOOST_CHECK(iss.bad()); \
+ \
+ number b(7); \
+ const char* i = input; \
+ std::wistringstream wiss(std::wstring(i, i + strlen(i))); wiss >> mod >> b; \
+ BOOST_CHECK_EQUAL(b, number(result)); \
+ if (!state) BOOST_CHECK(iss.bad()); \
+ } while (0)
+
+#define CHECK_ISS_STATE(input, result, state) CHECK_ISS_MOD_STATE(input, std::skipws, result, state)
+
+#define CHECK_ISS_MOD(input, mod, result) CHECK_ISS_MOD_STATE(input, mod, result, true)
+
+#define CHECK_ISS(input, result) CHECK_ISS_STATE(input, result, true)
+
+ // stream output
+
+ // simple
+ CHECK_OSS(number(10), "10");
+ CHECK_OSS(number(-10), "-10");
+
+ // bases
+ CHECK_OSS(std::oct << number(10), "12");
+ CHECK_OSS(std::oct << number(-10), "-12");
+ CHECK_OSS(std::hex << number(10), "a");
+ CHECK_OSS(std::hex << number(-10), "-a");
+ CHECK_OSS(std::hex << std::dec << number(10), "10");
+ CHECK_OSS(std::hex << std::dec << number(-10), "-10");
+
+ // showpos
+ CHECK_OSS(std::showpos << number(-1), "-1");
+ CHECK_OSS(std::showpos << number(0), "+0");
+ CHECK_OSS(std::showpos << number(1), "+1");
+
+ // showbase
+ CHECK_OSS(std::showbase << std::oct << number(10), "012");
+ CHECK_OSS(std::showbase << std::oct << number(-10), "-012");
+ CHECK_OSS(std::showbase << std::hex << number(10), "0xa");
+ CHECK_OSS(std::showbase << std::hex << number(-10), "-0xa");
+
+ // uppercase
+ CHECK_OSS(std::uppercase << std::hex << number(10), "A");
+ CHECK_OSS(std::uppercase << std::hex << number(-10), "-A");
+ CHECK_OSS(std::showbase << std::uppercase << std::hex << number(10), "0XA");
+ CHECK_OSS(std::showbase << std::uppercase << std::hex << number(-10), "-0XA");
+
+ // padding
+
+ // right
+ CHECK_OSS(std::setw(6) << number(10), " 10");
+ CHECK_OSS(std::setw(6) << number(-10), " -10");
+ CHECK_OSS(std::setw(6) << std::showbase << std::hex << number(10), " 0xa");
+ CHECK_OSS(std::setw(6) << std::showbase << std::oct << number(10), " 012");
+ CHECK_OSS(std::setw(6) << std::showbase << std::hex << number(-10), " -0xa");
+ CHECK_OSS(std::setw(6) << std::showbase << std::oct << number(-10), " -012");
+ CHECK_OSS(std::setw(6) << std::showpos << std::showbase << std::hex << number(10), " +0xa");
+ CHECK_OSS(std::setw(6) << std::showpos << std::showbase << std::oct << number(10), " +012");
+
+ // left
+ CHECK_OSS(std::left << std::setw(6) << number(10), "10 ");
+ CHECK_OSS(std::left << std::setw(6) << number(-10), "-10 ");
+ CHECK_OSS(std::left << std::setw(6) << std::showbase << std::hex << number(10), "0xa ");
+ CHECK_OSS(std::left << std::setw(6) << std::showbase << std::oct << number(10), "012 ");
+ CHECK_OSS(std::left << std::setw(6) << std::showbase << std::hex << number(-10), "-0xa ");
+ CHECK_OSS(std::left << std::setw(6) << std::showbase << std::oct << number(-10), "-012 ");
+ CHECK_OSS(std::left << std::setw(6) << std::showpos << std::showbase << std::hex << number(10), "+0xa ");
+ CHECK_OSS(std::left << std::setw(6) << std::showpos << std::showbase << std::oct << number(10), "+012 ");
+
+ // internal
+ CHECK_OSS(std::internal << std::setw(6) << number(10), " 10");
+ CHECK_OSS(std::internal << std::setw(6) << number(-10), "- 10");
+ CHECK_OSS(std::internal << std::setw(6) << std::showbase << std::hex << number(10), "0x a");
+ CHECK_OSS(std::internal << std::setw(6) << std::showbase << std::oct << number(10), " 012");
+ CHECK_OSS(std::internal << std::setw(6) << std::showbase << std::hex << number(-10), "-0x a");
+ CHECK_OSS(std::internal << std::setw(6) << std::showbase << std::oct << number(-10), "- 012");
+ CHECK_OSS(std::internal << std::setw(6) << std::showpos << std::showbase << std::hex << number(10), "+0x a");
+ CHECK_OSS(std::internal << std::setw(6) << std::showpos << std::showbase << std::oct << number(10), "+ 012");
+
+ // internal + fill
+ CHECK_OSS(setfillch << std::internal << std::setw(6) << number(10), "____10");
+ CHECK_OSS(setfillch << std::internal << std::setw(6) << number(-10), "-___10");
+ CHECK_OSS(setfillch << std::internal << std::setw(6) << std::showbase << std::hex << number(10), "0x___a");
+ CHECK_OSS(setfillch << std::internal << std::setw(6) << std::showbase << std::oct << number(10), "___012");
+ CHECK_OSS(setfillch << std::internal << std::setw(6) << std::showbase << std::hex << number(-10), "-0x__a");
+ CHECK_OSS(setfillch << std::internal << std::setw(6) << std::showbase << std::oct << number(-10), "-__012");
+ CHECK_OSS(setfillch << std::internal << std::setw(6) << std::showpos << std::showbase << std::hex << number(10), "+0x__a");
+ CHECK_OSS(setfillch << std::internal << std::setw(6) << std::showpos << std::showbase << std::oct << number(10), "+__012");
+
+ // padding + locale (thousands separator)
+ CHECK_OSS(std::setw(10) << setusanumlocale << number(1234567), " 1,234,567");
+ CHECK_OSS(std::setw(10) << setusanumlocale << number(-234567), " -234,567");
+ CHECK_OSS(std::setw(10) << setusanumlocale << std::showpos << number(234567), " +234,567");
+ CHECK_OSS(std::setw(10) << setusanumlocale << std::showbase << std::oct << number(234567), " 0712,107");
+
+ // stream input
+
+ // simple
+ CHECK_ISS("+123", "123");
+ CHECK_ISS("123", "123");
+ CHECK_ISS("-123", "-123");
+ CHECK_ISS("+0", "0");
+ CHECK_ISS("0", "0");
+ CHECK_ISS("-0", "0");
+
+ // spaces
+ CHECK_ISS(" \t-13", "-13");
+ CHECK_ISS_MOD(" \t-13", std::noskipws, "7");
+ CHECK_ISS("- 13", "7");
+ CHECK_ISS_MOD("- 13", std::noskipws, "7");
+
+ // bases
+ CHECK_ISS_MOD("13", std::oct, "11");
+ CHECK_ISS_MOD("-13", std::oct, "-11");
+ CHECK_ISS_MOD("ff", std::hex, "255");
+ CHECK_ISS_MOD("-ff", std::hex, "-255");
+ CHECK_ISS_MOD("11", std::oct >> std::dec, "11");
+ CHECK_ISS_MOD("-11", std::oct >> std::dec, "-11");
+
+ // separators
+ CHECK_ISS_MOD("1,234,567", setusanumlocale, "1234567");
+ CHECK_ISS_MOD("-234,567", setusanumlocale, "-234567");
+ CHECK_ISS_MOD("+234,567", setusanumlocale, "234567");
+ CHECK_ISS_MOD("0712,107", std::oct >> setusanumlocale, "234567");
+ CHECK_ISS_MOD("0x123,456", std::hex >> setusanumlocale, "1193046");
+
+ // whole input is incorrect - should leave variable untouched (and set bad state)
+ CHECK_ISS_STATE("JAKFDJLK", "7", false);
+ CHECK_ISS_STATE("-.3", "7", false);
+ CHECK_ISS_MOD_STATE("-3,,,", setusanumlocale, "7", false);
+ CHECK_ISS_MOD_STATE("-3,22", setusanumlocale, "7", false);
+ CHECK_ISS_MOD_STATE("-3,33,222,222", setusanumlocale, "7", false);
+
+ // input is partially incorrect - should read only correct part
+ {
+ number a;
+ std::istringstream iss("-384ABC");
+ iss >> a;
+
+ BOOST_CHECK_EQUAL(a, -384);
+ BOOST_CHECK_EQUAL(iss.get(), 65);
+ }
+
+ {
+ number b;
+ std::wistringstream wiss(L"-384ABC");
+ wiss >> b;
+
+ BOOST_CHECK_EQUAL(b, -384);
+ BOOST_CHECK_EQUAL(wiss.get(), 65);
+ }
+
+ {
+ number a;
+ std::istringstream iss("FFZYX");
+ iss >> std::hex >> a;
+
+ BOOST_CHECK_EQUAL(a, 255);
+ BOOST_CHECK_EQUAL(iss.get(), 90);
+ }
+
+ {
+ number b;
+ std::wistringstream wiss(L"FFZYX");
+ wiss >> std::hex >> b;
+
+ BOOST_CHECK_EQUAL(b, 255);
+ BOOST_CHECK_EQUAL(wiss.get(), 90);
+ }
+
+ {
+ number a;
+ std::istringstream iss("1238a");
+ iss >> std::oct >> a;
+
+ BOOST_CHECK_EQUAL(a, 83);
+ BOOST_CHECK_EQUAL(iss.get(), 56);
+ }
+
+ {
+ number b;
+ std::wistringstream wiss(L"1238a");
+ wiss >> std::oct >> b;
+
+ BOOST_CHECK_EQUAL(b, 83);
+ BOOST_CHECK_EQUAL(wiss.get(), 56);
+ }
+
+#undef CHECK_ISS
+#undef CHECK_OSS
+
+}
+
+int test_main(int argc, char* argv[])
+{
+ test<boost::detail::bigint_gmp_implementation>();
+
+ return 0;
+}
Modified: sandbox/SOC/2007/bigint/libs/bigint/test/string_conversion.cpp
==============================================================================
--- sandbox/SOC/2007/bigint/libs/bigint/test/string_conversion.cpp (original)
+++ sandbox/SOC/2007/bigint/libs/bigint/test/string_conversion.cpp 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
@@ -13,9 +13,7 @@
#include <boost/bigint/bigint.hpp>
-#include <sstream>
-
-#include <iostream>
+#include <string>
#pragma comment(lib, "libgmp-3.lib")
@@ -83,7 +81,7 @@
{-10, "ABCDEF", 0, 0},
{-10, "\xff", 0, 0},
// handling non-ASCII symbols
- {-36, "sa3mx\xa3\xb3", 47500521, 0},
+ {-36, "sa3mx\xa3\xb3", 47500521, 0}
};
for (size_t i = 0; i < ARRAY_SIZE(entries); ++i)
Added: sandbox/SOC/2007/bigint/libs/bigint/test/unary.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/bigint/libs/bigint/test/unary.cpp 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
@@ -0,0 +1,104 @@
+/* Boost unary.cpp test file
+ *
+ * Copyright 2007 Arseny Kapoulkine
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or
+ * copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#define BOOST_DISABLE_WIN32
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+#include <boost/bigint/bigint.hpp>
+
+#pragma comment(lib, "libgmp-3.lib")
+
+template <typename I> void test()
+{
+ typedef boost::bigint_base<I> number;
+
+ // ++
+ {
+ number a(4);
+
+ BOOST_CHECK_EQUAL(++a, 5);
+ BOOST_CHECK_EQUAL(a, 5);
+ BOOST_CHECK_EQUAL(a++, 5);
+ BOOST_CHECK_EQUAL(a, 6);
+
+ number b("999999999999");
+ BOOST_CHECK_EQUAL(++b, number("1000000000000"));
+ BOOST_CHECK_EQUAL(b, number("1000000000000"));
+ BOOST_CHECK_EQUAL(b++, number("1000000000000"));
+ BOOST_CHECK_EQUAL(b, number("1000000000001"));
+
+ number c(-2);
+ BOOST_CHECK_EQUAL(++c, -1);
+ BOOST_CHECK_EQUAL(c, -1);
+ BOOST_CHECK_EQUAL(c++, -1);
+ BOOST_CHECK_EQUAL(c, 0);
+ }
+
+ // --
+ {
+ number a(5);
+
+ BOOST_CHECK_EQUAL(--a, 4);
+ BOOST_CHECK_EQUAL(a, 4);
+ BOOST_CHECK_EQUAL(a--, 4);
+ BOOST_CHECK_EQUAL(a, 3);
+
+ number b("999999999999");
+ BOOST_CHECK_EQUAL(--b, number("999999999998"));
+ BOOST_CHECK_EQUAL(b, number("999999999998"));
+ BOOST_CHECK_EQUAL(b--, number("999999999998"));
+ BOOST_CHECK_EQUAL(b, number("999999999997"));
+
+ number c(1);
+ BOOST_CHECK_EQUAL(--c, 0);
+ BOOST_CHECK_EQUAL(c, 0);
+ BOOST_CHECK_EQUAL(c--, 0);
+ BOOST_CHECK_EQUAL(c, -1);
+ }
+
+ // +
+ {
+ BOOST_CHECK_EQUAL(+number("0"), number("0"));
+ BOOST_CHECK_EQUAL(+number("3"), number("3"));
+ BOOST_CHECK_EQUAL(+number("234905823945839453"), number("234905823945839453"));
+ BOOST_CHECK_EQUAL(+number("-1234912384"), number("-1234912384"));
+ }
+
+ // -
+ {
+ BOOST_CHECK_EQUAL(-number("0"), number("0"));
+ BOOST_CHECK_EQUAL(-number("3"), number("-3"));
+ BOOST_CHECK_EQUAL(-number("234905823945839453"), number("-234905823945839453"));
+ BOOST_CHECK_EQUAL(-number("-1234912384"), number("1234912384"));
+ }
+
+ // ~
+ {
+ BOOST_CHECK_EQUAL(~number("0"), number("-1"));
+ BOOST_CHECK_EQUAL(~number("3"), number("-4"));
+ BOOST_CHECK_EQUAL(~number("234905823945839453"), number("-234905823945839454"));
+ BOOST_CHECK_EQUAL(~number("-1234912384"), number("1234912383"));
+ }
+
+ // safe bool conversion and operator!
+ {
+ BOOST_CHECK(!number("0"));
+ BOOST_CHECK(number("3"));
+ BOOST_CHECK(number("-234893"));
+ BOOST_CHECK(number("-234893") != true); // this should always call operator!= for numbers, not test safe bool - check it
+ }
+}
+
+int test_main(int argc, char* argv[])
+{
+ test<boost::detail::bigint_gmp_implementation>();
+
+ return 0;
+}
Modified: sandbox/SOC/2007/bigint/libs/bigint/todo.txt
==============================================================================
--- sandbox/SOC/2007/bigint/libs/bigint/todo.txt (original)
+++ sandbox/SOC/2007/bigint/libs/bigint/todo.txt 2007-06-10 05:34:45 EDT (Sun, 10 Jun 2007)
@@ -12,7 +12,7 @@
------------ -------- ------
1. Bigint interface (header) 21 May Awaiting resolution
2. GMP implementation 21 May In progress
-3. Correctness tests 7 June N/A
+3. Correctness tests 7 June In progress
4. Documentation 21 June N/A
5. Performance tests 7 July N/A
4. Interface for storage 14 July N/A
@@ -59,6 +59,18 @@
* make sure it works on a wide range of compilers (test framework setup is needed)
Status: made some setup, it works for me but: 1. linking gmp is done via a hack, 2. not sure it works for others :/
++ stream output support: What modifiers do we need to support? Flags (skipws, etc.)?
+Status: investigated. showpos ('+' for positive numbers), showbase, oct/dec/hex, uppercase, width, adjust, thousands separators
+
++ stream output support with all needed modifiers and other things
+Status: implemented
+
++ stream input support: What modifiers do we need to support? Flags (skipws, etc.)?
+Status: investigated. oct/dec/hex, skipws, correctly handle (check) separators, set bad state on invalid input, etc.
+
++ stream input support with all needed modifiers and other things
+Status: implemented
+
2. GMP implementation
+ conversion from string with different bases (2-36, use 26 letters + 10 digits)
@@ -126,30 +138,33 @@
+ test basic arithmetics and modulo (both op= and op) - bigint op/= bigint, bigint op/= number, number op bigint
Status: implemented
-- test bit arithmetics - bigint op/= bigint, bigint op/= number, number op bigint (except << and >>)
-Status: needs implementing
++ test comparison operators
+Status: implemented
-- test increment/decrement (postfix/prefix)
-Status: needs implementing
++ test bit arithmetics - bigint op/= bigint, bigint op/= number, number op bigint (except << and >>)
+Status: implemented
-- test unary operators (+, -, ~) - don't forget to check that -0 == 0
-Status: needs implementing
++ test increment/decrement (postfix/prefix)
+Status: implemented
-- test bool conversion and operator!
-Status: needs implementing
++ test unary operators (+, -, ~) - don't forget to check that -0 == 0
+Status: implemented
-- test comparison operators
-Status: needs implementing
++ test bool conversion and operator!
+Status: implemented
-- test abs, pow, ldiv, sqrt
-Status: needs implementing
++ test stream input/output
+Status: implemented
-- test stream input/output
+- test abs, pow, ldiv, sqrt
Status: needs implementing
- test serialization
Status: needs implementing
+- Is it possible to test cases when bigint must cause illegal operations (division by zero, sqrt(negative number))?
+Status: needs investigation
+
-----------------------------------------------
Problem: GMP calls abort() when failing to allocate memory.
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk