mirror of
https://github.com/nlohmann/json.git
synced 2026-07-08 11:35:10 +00:00
♻️ implement floating-point special values
This commit is contained in:
@@ -15167,6 +15167,14 @@ class binary_writer
|
||||
{
|
||||
oa->write_character(to_char_type(0xFD));
|
||||
}
|
||||
else if (std::isnan(j.m_value.number_float))
|
||||
{
|
||||
oa->write_character(to_char_type(0x8E));
|
||||
oa->write_character(to_char_type(0x7F));
|
||||
oa->write_character(to_char_type(0x80));
|
||||
oa->write_character(to_char_type(0x00));
|
||||
oa->write_character(to_char_type(0x01));
|
||||
}
|
||||
else
|
||||
{
|
||||
// write float with prefix
|
||||
@@ -15413,9 +15421,9 @@ class binary_writer
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#endif
|
||||
if (static_cast<double>(n) >= static_cast<double>(std::numeric_limits<float>::lowest()) &&
|
||||
static_cast<double>(n) <= static_cast<double>((std::numeric_limits<float>::max)()) &&
|
||||
static_cast<double>(static_cast<float>(n)) == static_cast<double>(n))
|
||||
if (std::isnan(n) || std::isinf(n) || (static_cast<double>(n) >= static_cast<double>(std::numeric_limits<float>::lowest()) &&
|
||||
static_cast<double>(n) <= static_cast<double>((std::numeric_limits<float>::max)()) &&
|
||||
static_cast<double>(static_cast<float>(n)) == static_cast<double>(n)))
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user