Skip to content

Commit

Permalink
handle negative values when "cast"ing t_float to uint
Browse files Browse the repository at this point in the history
doing a static_cast<unsigned int>(-1.) will return 0xffffff!!!
  • Loading branch information
umlaeute committed Jan 8, 2014
1 parent 404d30a commit 42a48c3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/RTE/MessageCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace gem {
template<>
struct TypeTemplate<unsigned int> : TypeTemplateCore<t_float, unsigned int> {
static t_atomtype atomtype_id(void) { return A_FLOAT; }
static unsigned int cast(t_float f) { return (f>0.)?static_cast<unsigned int>(f):0; }
};
template<>
struct TypeTemplate<bool> : TypeTemplateCore<t_float, bool> {
Expand Down

0 comments on commit 42a48c3

Please sign in to comment.