Skip to content

Commit 7bb5e38

Browse files
committed
solve issue #506
1 parent fada3ef commit 7bb5e38

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

include/behaviortree_cpp/utils/convert_impl.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ void convertNumber( const SRC& source, DST& target )
142142
// casting to/from floating points might cause truncation.
143143
else if constexpr( std::is_floating_point<SRC>::value || std::is_floating_point<DST>::value )
144144
{
145-
checkTruncation<SRC,DST>(source);
145+
bool both_float = std::is_floating_point<SRC>::value && std::is_floating_point<DST>::value;
146+
// to avoid being too pedantic, let's accept casting between double and float
147+
if(!both_float){
148+
checkTruncation<SRC,DST>(source);
149+
}
146150
target = static_cast<DST>(source);
147151
}
148152
}

0 commit comments

Comments
 (0)