Skip to content

Commit

Permalink
MatlabApi/gason: changed default float decimal precision to 12 (helpf…
Browse files Browse the repository at this point in the history
…ul since some ids are 12 decimals long)
  • Loading branch information
pdollar committed Jul 17, 2016
1 parent de2ee0e commit f6f2551
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions MatlabAPI/private/gasonMex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void mexFunction( int nl, mxArray *pl[], int nr, const mxArray *pr[] )
pl[0] = json(val); mxFree(str);
} else {
// string = mexFunction( object )
ostrm S; S << std::setprecision(10); json(S,pr[0]);
ostrm S; S << std::setprecision(12); json(S,pr[0]);
pl[0]=mxCreateStringRobust(S.str().c_str());
}

Expand All @@ -203,7 +203,7 @@ void mexFunction( int nl, mxArray *pl[], int nr, const mxArray *pr[] )
if( val.getTag()!=JSON_ARRAY ) mexErrMsgTxt("Array expected");
siz i=0, t=0, n=length(val), k=(siz) mxGetScalar(pr[1]);
k=(k>n)?n:(k<1)?1:k; k=ceil(n/ceil(double(n)/k));
pl[0]=mxCreateCellMatrix(1,k); ostrm S; S<<std::setprecision(10);
pl[0]=mxCreateCellMatrix(1,k); ostrm S; S<<std::setprecision(12);
for(auto o:val) {
if(!t) { S.str(std::string()); S << "["; t=ceil(double(n)/k); }
json(S,&o->value); t--; if(!o->next) t=0; S << (t ? "," : "]");
Expand All @@ -215,7 +215,7 @@ void mexFunction( int nl, mxArray *pl[], int nr, const mxArray *pr[] )
if( nr!=1 ) mexErrMsgTxt("One input expected.");
if(!mxIsCell(pr[0])) mexErrMsgTxt("Cell array expected.");
siz n = mxGetNumberOfElements(pr[0]);
ostrm S; S << std::setprecision(10); S << "[";
ostrm S; S << std::setprecision(12); S << "[";
for( siz i=0; i<n; i++ ) {
char *str = mxArrayToStringRobust(mxGetCell(pr[0],i));
int status = jsonParse(str, &endptr, &val, allocator);
Expand Down
Binary file modified MatlabAPI/private/gasonMex.mexa64
Binary file not shown.
Binary file modified MatlabAPI/private/gasonMex.mexmaci64
Binary file not shown.

0 comments on commit f6f2551

Please sign in to comment.