Menu

#145 json negative floats throws bad_cast

cppcms-v1.0.x
closed
None
1
2016-04-04
2016-03-17
Anonymous
No

double r=v.number();
if( r < std::numeric_limits<float>::min()
|| std::numeric_limits<float>::max() < r )
{
throw bad_value_cast();</float></float>

std::numeric_limits<float>::min() rules out negative floats IMHO.</float>

The JSON standards allows negative numbers as values, if I am correct.
cmmcps version is 1.0.5

Discussion

  • Artyom Beilis

    Artyom Beilis - 2016-03-17
    • status: open --> accepted
    • assigned_to: Artyom Beilis
     
  • Artyom Beilis

    Artyom Beilis - 2016-03-17

    Thank You,

    Yes you are correct, I incorrectly assumed that std::numeric_limits<float>::min() returns real minimal value rather than minimal positive value.</float>

    I'll fix it.

     
  • Andreas Baumann

    Andreas Baumann - 2016-03-18

    Thanks for the fast reaction. :-)

    Sorry, by no means I wanted to post this anonymously..

    I'm using the JSON serializer for more than just reading configurations: for a
    webservice using JSON as communication protocol. That's why I'm hitting some
    corner cases right now, I think.

     
  • Artyom Beilis

    Artyom Beilis - 2016-04-04
    • status: accepted --> closed
     
  • Artyom Beilis

    Artyom Beilis - 2016-04-04

    Fixed in 2413

     

Anonymous
Anonymous

Add attachments
Cancel