Warning fix
This fixes ary_to_int() for negative values
This commit is contained in:
parent
a5705c5be0
commit
79ca881bc1
2 changed files with 13 additions and 8 deletions
|
@ -166,6 +166,13 @@ namespace dhandy {
|
|||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
[[gnu::always_inline,gnu::pure]]
|
||||
inline T negated_ifn (T n, bool negate) {
|
||||
//return static_cast<int32_t>(((static_cast<unsigned int>(n) - (mask bitand 1)) xor mask) bitor ((mask bitand 1) << 31));
|
||||
return (negate ? -n : n);
|
||||
}
|
||||
|
||||
template <typename I, unsigned int Base, typename Tr>
|
||||
struct AryConversion {
|
||||
template <typename C>
|
||||
|
@ -183,7 +190,7 @@ namespace dhandy {
|
|||
retval += Tr::from_digit(beg[i]) * factor;
|
||||
factor *= Base;
|
||||
}
|
||||
return retval;
|
||||
return negated_ifn(retval, was_negative);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -204,13 +211,6 @@ namespace dhandy {
|
|||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
[[gnu::always_inline,gnu::pure]]
|
||||
inline T negated_ifn (T n, bool negate) {
|
||||
//return static_cast<int32_t>(((static_cast<unsigned int>(n) - (mask bitand 1)) xor mask) bitor ((mask bitand 1) << 31));
|
||||
return (negate ? -n : n);
|
||||
}
|
||||
|
||||
template <typename T, typename C, unsigned int Base, typename Tr>
|
||||
[[gnu::pure]]
|
||||
T to_integer_sse (const C* s, std::size_t l) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue