To use the node in your project you should have the danya/stringtonumber library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.
C++ implementation
struct State {
};
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
auto state = getState(ctx);
auto xString = getValue<input_IN>(ctx);
int N = length(xString) + 1;
char cString[N];
int b;
int count;
int len;
Number roundout;
for(int i=0;i<N;i++)
cString[i]=0;
dump(xString,cString);
Number nout= atof(cString);
for (b = floor(nout); b>0; b = (b / 10)){
count++;
}
if (round(nout) != nout){
len = N-2;
}
else{
len = N - 1;
}
len = ((round(len) - round(count))+1);
roundout = round(pow(10, floor(len)));
nout = (round(nout*roundout)/roundout);
emitValue<output_OUT>(ctx, nout);
}