mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 15:21:54 +00:00
Reduce bigint capacity
This commit is contained in:
parent
a5abe5d95c
commit
646966e973
@ -17,7 +17,6 @@
|
|||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstddef> // for std::ptrdiff_t
|
|
||||||
#include <cstring> // for std::memmove
|
#include <cstring> // for std::memmove
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
||||||
@ -495,7 +494,8 @@ class bigint {
|
|||||||
// 0 being the least significant one.
|
// 0 being the least significant one.
|
||||||
using bigit = uint32_t;
|
using bigit = uint32_t;
|
||||||
using double_bigit = uint64_t;
|
using double_bigit = uint64_t;
|
||||||
basic_memory_buffer<bigit> bigits_;
|
enum { bigits_capacity = 32 };
|
||||||
|
basic_memory_buffer<bigit, bigits_capacity> bigits_;
|
||||||
int exp_;
|
int exp_;
|
||||||
|
|
||||||
static FMT_CONSTEXPR_DECL const int bigit_bits = bits<bigit>::value;
|
static FMT_CONSTEXPR_DECL const int bigit_bits = bits<bigit>::value;
|
||||||
@ -559,6 +559,7 @@ class bigint {
|
|||||||
public:
|
public:
|
||||||
bigint() : exp_(0) {}
|
bigint() : exp_(0) {}
|
||||||
explicit bigint(uint64_t n) { assign(n); }
|
explicit bigint(uint64_t n) { assign(n); }
|
||||||
|
~bigint() { assert(bigits_.capacity() <= bigits_capacity); }
|
||||||
|
|
||||||
bigint(const bigint&) = delete;
|
bigint(const bigint&) = delete;
|
||||||
void operator=(const bigint&) = delete;
|
void operator=(const bigint&) = delete;
|
||||||
@ -664,7 +665,7 @@ class bigint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void square() {
|
void square() {
|
||||||
basic_memory_buffer<bigit> n(std::move(bigits_));
|
basic_memory_buffer<bigit, bigits_capacity> n(std::move(bigits_));
|
||||||
int num_bigits = static_cast<int>(bigits_.size());
|
int num_bigits = static_cast<int>(bigits_.size());
|
||||||
int num_result_bigits = 2 * num_bigits;
|
int num_result_bigits = 2 * num_bigits;
|
||||||
bigits_.resize(num_result_bigits);
|
bigits_.resize(num_result_bigits);
|
||||||
@ -941,7 +942,7 @@ FMT_FUNC void fallback_format(Double v, buffer<char>& buf, int& exp10) {
|
|||||||
fp fp_value(v);
|
fp fp_value(v);
|
||||||
// Shift to account for unequal gaps when lower boundary is 2 times closer.
|
// Shift to account for unequal gaps when lower boundary is 2 times closer.
|
||||||
// TODO: handle denormals
|
// TODO: handle denormals
|
||||||
int shift = fp_value.f == 1 ? 1 : 0;
|
int shift = 0; //fp_value.f == 1 ? 1 : 0;
|
||||||
bigint numerator; // 2 * R in (FPP)^2.
|
bigint numerator; // 2 * R in (FPP)^2.
|
||||||
bigint denominator; // 2 * S in (FPP)^2.
|
bigint denominator; // 2 * S in (FPP)^2.
|
||||||
bigint lower; // (M^- in (FPP)^2).
|
bigint lower; // (M^- in (FPP)^2).
|
||||||
|
Loading…
Reference in New Issue
Block a user