osaf/libs/common/immsv/immpbe_dump.cc | 2 ++ osaf/tools/safimm/immlist/imm_list.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-)
Set a correct floating point precision for printed and dumped float and double values, so that the floating point precision is not lost when the floating point value in a string representation is converted back to float and double value. diff --git a/osaf/libs/common/immsv/immpbe_dump.cc b/osaf/libs/common/immsv/immpbe_dump.cc --- a/osaf/libs/common/immsv/immpbe_dump.cc +++ b/osaf/libs/common/immsv/immpbe_dump.cc @@ -3176,9 +3176,11 @@ std::string valueToString(SaImmAttrValue ost << *((unsigned long long *) value); break; case SA_IMM_ATTR_SAFLOATT: + ost.precision(8); ost << *((float *) value); break; case SA_IMM_ATTR_SADOUBLET: + ost.precision(17); ost << *((double *) value); break; case SA_IMM_ATTR_SANAMET: diff --git a/osaf/tools/safimm/immlist/imm_list.c b/osaf/tools/safimm/immlist/imm_list.c --- a/osaf/tools/safimm/immlist/imm_list.c +++ b/osaf/tools/safimm/immlist/imm_list.c @@ -96,10 +96,10 @@ static void print_attr_value_raw(SaImmVa printf("%llu", *((SaTimeT *)attrValue)); break; case SA_IMM_ATTR_SAFLOATT: - printf("%f", *((SaFloatT *)attrValue)); + printf("%.8g", *((SaFloatT *)attrValue)); break; case SA_IMM_ATTR_SADOUBLET: - printf("%17.15f", *((SaDoubleT *)attrValue)); + printf("%.17g", *((SaDoubleT *)attrValue)); break; case SA_IMM_ATTR_SANAMET: { SaNameT *myNameT = (SaNameT *)attrValue; @@ -158,10 +158,10 @@ static void print_attr_value(SaImmValueT break; } case SA_IMM_ATTR_SAFLOATT: - printf("%f ", *((SaFloatT *)attrValue)); + printf("%.8g", *((SaFloatT *)attrValue)); break; case SA_IMM_ATTR_SADOUBLET: - printf("%17.15f", *((SaDoubleT *)attrValue)); + printf("%.17g", *((SaDoubleT *)attrValue)); break; case SA_IMM_ATTR_SANAMET: { ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel