user44976: I am using an Arduino simulator on www.tinkercad.com (a seemingly nice free product from Autodesk).  Working on conversion of an integer to a 16 bit binary string for output to a DAC, but unfortunately even at the first step I am getting unexpected behavior.  
void setup()
{
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  Serial.print("Sanity Check\n");
  uint16_t num = 12000;
  Serial.print("\nNumber: " + String(num) + "\n");
  delay(3000);
}

Surprisingly the above code gave the following output:
Sanity Check

Number: 12222

Is there something I am doing wrong, or something wrong with the simulator?   The error seems to crop up with any value over 10000.  10001, 10002, 10003 all print as 10000.  11000, 11001, 11002, 11003 all print as 11111.  etc, etc.  What could be going on?  

user31668: Tinkercad is (was) a very good simulator but it has stopped updates.
Here is the output from the free Arduino simulator from here
This project is used for the below screenshot

Here is an article pointing some more features of the simulator

user30175: Bug. No other explanation. Real hardware (Arduino Uno) prints 12000.
Even the debugger tells me that the value of that variable is 12000.

Outputs:
Number: 12222 
12000 
12222 something 

Most interestingly if you Serial.println() the number, it is outputted correctly. The bug must be in the constructor of the String object, as demonstrated by the "test" String. This bug also occurs on other data types, e.g. int.
If you only use direct Serial.print[ln] calls you should be able to workaround that bug.

44976: <p>I am using an Arduino simulator on <a href="http://www.tinkercad.com" rel="nofollow noreferrer">www.tinkercad.com</a> (a seemingly nice free product from Autodesk).  Working on conversion of an integer to a 16 bit binary string for output to a DAC, but unfortunately even at the first step I am getting unexpected behavior.  </p>

<pre><code>void setup()
{
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  Serial.print("Sanity Check\n");
  uint16_t num = 12000;
  Serial.print("\nNumber: " + String(num) + "\n");
  delay(3000);
}
</code></pre>

<p>Surprisingly the above code gave the following output:</p>

<pre><code>Sanity Check

Number: 12222
</code></pre>

<p>Is there something I am doing wrong, or something wrong with the simulator?   The error seems to crop up with any value over 10000.  10001, 10002, 10003 all print as 10000.  11000, 11001, 11002, 11003 all print as 11111.  etc, etc.  What could be going on?  </p>
 31668: <p>Tinkercad is (was) a very good simulator but it has stopped updates.
Here is the output from the free Arduino simulator from <a href="https://wokwi.com" rel="nofollow noreferrer">here</a></p>
<p>This <a href="https://wokwi.com/arduino/projects/295390167781343757" rel="nofollow noreferrer">project</a> is used for the below screenshot</p>
<p><a href="https://i.stack.imgur.com/RhmHv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RhmHv.png" alt="enter image description here" /></a></p>
<p>Here is an <a href="https://www.hackster.io/write2puneeth/tinkercad-versus-wokwi-arduino-simulator-5ab08d" rel="nofollow noreferrer">article</a> pointing some more features of the simulator</p>
 30175: <p>Bug. No other explanation. Real hardware (Arduino Uno) prints 12000.</p>

<p>Even the debugger tells me that the value of that variable is 12000.</p>

<p><a href="https://i.stack.imgur.com/LUBeJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LUBeJ.png" alt="debug"></a></p>

<p>Outputs:</p>

<pre><code>Number: 12222 
12000 
12222 something 
</code></pre>

<p>Most interestingly if you <code>Serial.println()</code> the number, it is outputted correctly. The bug must be in the constructor of the <code>String</code> object, as demonstrated by the "test" <code>String</code>. This bug also occurs on other data types, e.g. <code>int</code>.</p>

<p>If you only use direct <code>Serial.print[ln]</code> calls you should be able to workaround that bug.</p>
