Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
Loading...
Searching...
No Matches
decimal_converter.hpp File Reference
#include <string>
#include <iomanip>
#include <sstream>
#include <universal/number/support/decimal.hpp>
#include <universal/number/support/dragon.hpp>
#include <universal/number/support/grisu.hpp>

Namespaces

namespace  sw
 required std libraries
namespace  sw::universal
namespace  sw::universal::internal

Macros

#define DECIMAL_CONVERTER_USE_GRISU

Functions

template<unsigned fbits>
support::decimal sw::universal::extract_mantissa_from_value (const internal::value< fbits > &v)
 extract_mantissa_from_value: convert value<fbits> fraction to decimal value<> stores: (sign, scale, fraction_without_hidden_bit) The value is: (-1)^sign * 1.fraction * 2^scale We need to create a decimal representing the significand: 1.fraction = 1 + fraction as an integer: (2^fbits + fraction_bits)
template<unsigned fbits>
std::string sw::universal::to_decimal_string (const internal::value< fbits > &v, std::ios_base::fmtflags flags=std::ios_base::dec, std::streamsize precision=6)
 to_decimal_string: convert value<fbits> to decimal string representation
std::ostream & sw::universal::decimal_format_inserter (std::ostream &ostr, const std::string &decimal_str)
 decimal_format_inserter: helper to format and insert decimal strings into streams Respects stream width, fill, and alignment

Macro Definition Documentation

◆ DECIMAL_CONVERTER_USE_GRISU

#define DECIMAL_CONVERTER_USE_GRISU