Prev Next base_to_string

@(@\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@This is cppad-20221105 documentation. Here is a link to its current documentation .
Extending to_string To Another Floating Point Type

Base Requirement
If the function to_string is used by an AD type above Base , A specialization for the template structure CppAD::to_string_struct must be defined.

CPPAD_TO_STRING
For most Base types, the following can be used to define the specialization:
    namespace CppAD {
        CPPAD_TO_STRING(
Base)
    }
Note that the CPPAD_TO_STRING macro assumes that the base_limits and base_std_math have already been defined for this type. This macro is defined as follows:
# define CPPAD_TO_STRING(Base) \
template <> struct to_string_struct<Base>\
{   std::string operator()(const Base& value) \
    {   std::stringstream os;\
        int n_digits = 1 + CppAD::numeric_limits<Base>::digits10; \
        os << std::setprecision(n_digits);\
        os << value;\
        return os.str();\
    }\
};

Input File: include/cppad/core/base_to_string.hpp