Skip to content

Commit

Permalink
fixed NaN in JSON (fixes #225)
Browse files Browse the repository at this point in the history
  • Loading branch information
john30 committed Dec 2, 2018
1 parent 224c947 commit 8ed1e4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib/ebus/datatype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,14 @@ result_t NumberDataType::readSymbols(size_t offset, size_t length, const SymbolS
}
}
#endif
if (isnan(val)) {
if (outputFormat & OF_JSON) {
*output << "null";
} else {
*output << nullptr_VALUE;
}
return RESULT_OK;
}
if (val != 0.0) {
if (m_divisor < 0) {
val *= static_cast<float>(-m_divisor);
Expand Down
1 change: 1 addition & 0 deletions src/lib/ebus/test/test_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ int main() {
{"x,,exp", "-32.767", "10feffff04681103c2", "00", ""},
{"x,,exp,1000", "-0.000090000", "10feffff04ec51b8bd", "00", ""},
{"x,,exp,-100", "-9", "10feffff04ec51b8bd", "00", ""},
{"x,,exp", "-", "10feffff040000c07f", "00", "W"},
{"x,,exr", "-0.09", "10feffff04bdb851ec", "00", ""},
{"x,,exr", "0.0", "10feffff0400000000", "00", ""},
{"x,,exr", "-0.001", "10feffff04ba83126f", "00", ""},
Expand Down

0 comments on commit 8ed1e4f

Please sign in to comment.