Don't set terminal flags twice in a row
[deliverable/binutils-gdb.git] / gdb / ada-valprint.c
index 8095eede72192c1d29795e7d4cdd2fe7be3b1ce4..91dc301af5f2d0f9f31e36c796dd605ebc90db6b 100644 (file)
@@ -31,6 +31,7 @@
 #include "c-lang.h"
 #include "infcall.h"
 #include "objfiles.h"
+#include "target-float.h"
 
 static int print_field_values (struct type *, const gdb_byte *,
                               int,
@@ -796,10 +797,15 @@ ada_val_print_num (struct type *type, const gdb_byte *valaddr,
 {
   if (ada_is_fixed_point_type (type))
     {
-      LONGEST v = unpack_long (type, valaddr + offset_aligned);
-
-      fprintf_filtered (stream, TYPE_LENGTH (type) < 4 ? "%.11g" : "%.17g",
-                       (double) ada_fixed_to_float (type, v));
+      struct value *scale = ada_scaling_factor (type);
+      struct value *v = value_from_contents (type, valaddr + offset_aligned);
+      v = value_cast (value_type (scale), v);
+      v = value_binop (v, scale, BINOP_MUL);
+
+      const char *fmt = TYPE_LENGTH (type) < 4 ? "%.11g" : "%.17g";
+      std::string str
+       = target_float_to_string (value_contents (v), value_type (v), fmt);
+      fputs_filtered (str.c_str (), stream);
       return;
     }
   else if (TYPE_CODE (type) == TYPE_CODE_RANGE)
This page took 0.023287 seconds and 4 git commands to generate.