# Different result, simulation vs debug

**URL:** <https://forum.xod.io/t/different-result-simulation-vs-debug/3384>\
**Category:** Uncategorized\
**Created:** [January 29, 2020, 8:02am UTC](https://forum.xod.io/t/different-result-simulation-vs-debug/3384 "2020-01-29T08:02:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [January 29, 2020, 8:02am UTC](https://forum.xod.io/t/different-result-simulation-vs-debug/3384/1 "2020-01-29T08:02:58Z")

</div>

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?

```auto
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](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/d/d2dcbc120da7b14a332f18d45e7729fccaf3e5bc.png)

Debug  
 ![image](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/e/e5aa20b42f49ba642f8b2ec1ff231900339ac00b.png)

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [January 29, 2020, 9:18pm UTC](https://forum.xod.io/t/different-result-simulation-vs-debug/3384/2 "2020-01-29T21:18:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [January 29, 2020, 9:26pm UTC](https://forum.xod.io/t/different-result-simulation-vs-debug/3384/3 "2020-01-29T21:26:17Z")

</div>

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().

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [January 29, 2020, 9:31pm UTC](https://forum.xod.io/t/different-result-simulation-vs-debug/3384/4 "2020-01-29T21:31:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [January 29, 2020, 9:32pm UTC](https://forum.xod.io/t/different-result-simulation-vs-debug/3384/5 "2020-01-29T21:32:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [January 29, 2020, 9:57pm UTC](https://forum.xod.io/t/different-result-simulation-vs-debug/3384/6 "2020-01-29T21:57:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![uther2017](https://avatars.discourse-cdn.com/v4/letter/u/e19adc/32.png) [@uther2017](https://forum.xod.io/u/uther2017)\
**Post date:** [January 30, 2020, 5:40am UTC](https://forum.xod.io/t/different-result-simulation-vs-debug/3384/7 "2020-01-30T05:40:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [January 30, 2020, 3:25pm UTC](https://forum.xod.io/t/different-result-simulation-vs-debug/3384/8 "2020-01-30T15:25:06Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/eb7348baa04192c2ef932d1db54d44f09f8a7888.png) [@system](https://forum.xod.io/u/system)\
**Post date:** [February 1, 2020, 3:25pm UTC](https://forum.xod.io/t/different-result-simulation-vs-debug/3384/9 "2020-02-01T15:25:07Z")

</div>

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