Different result, simulation vs debug

Why get a different result? If I simulate it the result is different than if I charge it on the board.
What am I wrong about?

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    auto state = getState(ctx);
    auto str = getValue<input_IN>(ctx);
    char _str[16];
    dump(str,_str);
    emitValue<output_OUT>(ctx, atoi(_str));
}

Simulation
image

Debug
image

Fascinating…I get the exact same result with Arduino UNO.

Looks like some kind of overflow problem. It works through 32767, but 32768 displays as -32768. It works for your example if you replace atoi() with atof().

1 Like

Thanks for trying it, I don’t know if my code will be fine

Use atof() instead of atoi() if you want larger numbers (didn’t know if you would notice my edit above).

later I will do some tests, this node was for the melody library, but there I only used one bit, I had no problems.
Now trying to do something for an array I found this and I get disoriented, on top of that I understand little about C ++.

thanks

Yeah. I know nothing of c ++, if I did I would probably not even be using xod. I think the reason why I xod is because it allows me to easily program without knowing how to use a super complicated programming language.
Xod is also confusing enough to make me feel like I’m not a complete dummy using it. I’m forced to think about processes and understand what is going one and I love that.

Glad we have a work-around, but it does point out a bug/feature…simulation is using a different size int than Arduino board(s).

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.