#include <iostream>
#include <math.h>
#include "include/Parser.h"
#include </usr/local/include/mysql++/mysql++.h>
#include "/usr/local/include/mysql++/cmdline.h"
#include </usr/include/mysql/mysql_version.h>
#include "/usr/lib/jsoncpp/include/json/json.h"
int main( int argc, char * argv[] )
{
Json::Value lat = parser["geo"]["lat"];
cout << "latitude = " <<lat.toStyledString()<< endl;
}
将值传递给此参数后,我的纬度值为42.3577770。我想将其设为42.35,我该怎么做?
我试过
cout << setprecision(2) << fixed << lat.toStyledString() << '\n';
但它不起作用。还有其他办法吗?
答案 0 :(得分:1)
cout << setprecision(2) << fixed << lat.asDouble() << '\n';
(根据Json :: Value的在线文档)
答案 1 :(得分:0)
您想放弃toStyledString()
并使用float
:
cout << setprecision(2) << fixed << lat << '\n';