TarsCloud / TarsCpp

C++ language framework rpc source code implementation
BSD 3-Clause "New" or "Revised" License
520 stars 254 forks source link

[bug] c++版本readFromJson()处理浮点数科学计数法的错误 #286

Closed sunjingji closed 1 year ago

sunjingji commented 1 year ago

double类型的字段,例如1.32e1,调用getNum()函数得到的值时1.32,指数部分e1丢掉了。 经debug,可以发行代码里面有个bug。

tars/TarsCpp/util/src/tc_json.cpp: JsonValueNumPtr TC_Json::getNum(BufferJsonReader & reader,char head)

        else if(c>=0x30 && c<=0x39)
        { 
          bOk=true;
          bExponential=(bool)(c-0x30);
          //加上这一行就对了:iExponential=c-0x30;
        }
ruanshudong commented 1 year ago

麻烦提交一个pr

ruanshudong commented 1 year ago

不对啊, 你用啥版本啊, 新版本早已经有这一行了吧?

sunjingji commented 1 year ago

3.0.12还没有这一行的,新版本不太清楚

ruanshudong commented 1 year ago

具体是哪一行?

ruanshudong commented 1 year ago

bug fix

sunjingji commented 1 year ago

谢谢,真快,我还没来得及提交PR