I'm comparing values from regular floating point arithmetic and using a high-precision MPFR number as a baseline. When printing, I'm confused why the following code is output different.
The MPFR documentation says the output specifiers are
‘a’ ‘A’ hex float, C99 style"
So I would assume it prints the same as printf
. However, this is not the case:
#include <boost/multiprecision/mpfr.hpp>
#include <mpfr.h>
using namespace boost::multiprecision;
int main (int argc, char* argv[])
{
double a = 254.5;
mpfr_float_1000 mpfr_a = 254.5;
mpfr_t t;
mpfr_init2(t, 3324); // 1000 decimal precision
mpfr_set_d(t, a, MPFR_RNDN);
printf("double:\t%a\n", a);
mpfr_printf("mpfr_t:\t%RNa\n", t);
mpfr_printf("boost:\t%RNa\n", mpfr_a);
}
Gives output:
double: 0x1.fdp+7
mpfr_t: 0xf.e8p+4
boost: 0xf.e8p+4
It's not a huge deal because sscanf
parses both of them as the same value, but I couldn't locate any documentation explaining why they are different.
Which one is canonical?