17template<
typename T,
int S>
18inline void UIntF<T, S>::set_from_str(
const StringRefNull
str,
const int base)
22 mpz_set_str(x,
str.c_str(), base);
23 for (
int i = 0; i < S; i++) {
24 static_assert(
sizeof(
T) <=
sizeof(
decltype(mpz_get_ui(x))));
25 this->
v[i] =
T(mpz_get_ui(x));
26 mpz_div_2exp(x, x, 8 *
sizeof(T));
31template<
typename T,
int S>
32inline void IntF<T, S>::set_from_str(
const StringRefNull
str,
const int base)
35 const UIntF<T, S> unsigned_value(
str.c_str() + 1, base);
36 this->
v = unsigned_value.v;
40 const UIntF<T, S> unsigned_value(
str.c_str(), base);
41 this->
v = unsigned_value.v;
45template<
typename T,
int S>
inline std::string UIntF<T, S>::to_string(
const int base)
const
49 for (
int i = S - 1; i >= 0; i--) {
50 static_assert(
sizeof(
T) <=
sizeof(
decltype(mpz_get_ui(x))));
51 mpz_mul_2exp(x, x, 8 *
sizeof(T));
52 mpz_add_ui(x, x, this->
v[i]);
56 const int str_size = mpz_sizeinbase(x, base) + 2;
57 Array<char, 1024>
str(str_size);
58 mpz_get_str(
str.data(), base, x);
60 return std::string(
str.data());
63template<
typename T,
int S>
inline std::string IntF<T, S>::to_string(
const int base)
const
66 std::string
str = UIntF<T, S>(-*
this).to_string(base);
67 str.insert(
str.begin(),
'-');
70 return UIntF<T, S>(*this).to_string();
ATTR_WARN_UNUSED_RESULT const BMVert * v
bool is_negative(const IntF< T, Size > &a)