Skip to content

Commit 304c92c

Browse files
author
Thomas Kiley
committed
Adapt full_lhs_value to output binary for floating values
This is a precise representation of the floats, which can be useful
1 parent e57e194 commit 304c92c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/goto-programs/xml_goto_trace.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ Author: Daniel Kroening
1919
#include <util/xml_irep.h>
2020

2121
#include <langapi/language_util.h>
22+
#include <util/arith_tools.h>
2223

2324
#include "printf_formatter.h"
2425
#include "xml_expr.h"
2526

27+
bool full_lhs_value_includes_binary(
28+
const goto_trace_stept &step,
29+
const namespacet &ns)
30+
{
31+
return can_cast_type<floatbv_typet>(step.full_lhs_value.type());
32+
}
33+
2634
xmlt full_lhs_value(const goto_trace_stept &step, const namespacet &ns)
2735
{
2836
xmlt full_lhs_value{"full_lhs_value"};
@@ -33,6 +41,13 @@ xmlt full_lhs_value(const goto_trace_stept &step, const namespacet &ns)
3341

3442
if(step.full_lhs_value.is_not_nil())
3543
full_lhs_value.data = from_expr(ns, identifier, step.full_lhs_value);
44+
if(full_lhs_value_includes_binary(step, ns))
45+
{
46+
const auto width = to_floatbv_type(step.full_lhs_value.type()).get_width();
47+
const auto binary_representation = integer2binary(
48+
bvrep2integer(step.full_lhs_value.get(ID_value), width, false), width);
49+
full_lhs_value.set_attribute("binary", binary_representation);
50+
}
3651
return full_lhs_value;
3752
}
3853

0 commit comments

Comments
 (0)