user61040: I have a tiny circuit Bluetooth shield and I was testing out the sample code that was provided by tinycircuit. However, when I tried uploading the sample code into the board, I kept having the following error. How can I solve this error? 

this is the piece of code where there error seems to be happening.
#define  ADV_INTERVAL_MIN_MS  50
#define  ADV_INTERVAL_MAX_MS  100

void setConnectable(void)
{
  tBleStatus ret;

  const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME, 'B', 'l', 'u', 'e', 'N', 'R', 'G'};

  hci_le_set_scan_resp_data(0, NULL);
  PRINTF("General Discoverable Mode.\n");

  ret = aci_gap_set_discoverable(ADV_IND,
                                 (ADV_INTERVAL_MIN_MS * 1000) / 625, (ADV_INTERVAL_MAX_MS * 1000) / 625,
                                 STATIC_RANDOM_ADDR, NO_WHITE_LIST_USE,
                                 sizeof(local_name), local_name, 0, NULL, 0, 0);

  if (ret != BLE_STATUS_SUCCESS)
    PRINTF("%d\n", (uint8_t)ret);

}


user7508: You can specify the type of a number using suffixes such as L, LL,
UL and such. If you don't specify the type this way, all integers that
are small enough to fit in an int will be of type int. When you
write
ADV_INTERVAL_MIN_MS * 1000

it gets expanded by the preprocessor to
50 * 1000

Since both arguments are of type int, the compiler will use this type
to compute the result. However, the result is 50,000, and on 16-bit
systems the largest number that can fit in an int is 32,767, thus the
overflow.
As suggested by Majenko, the simple solution is to add the L suffix
(for long) to either operand. The compiler will then do the
arithmetics using the long data type.

61040: <p>I have a tiny circuit Bluetooth shield and I was testing out the sample code that was provided by tinycircuit. However, when I tried uploading the sample code into the board, I kept having the following error. How can I solve this error? </p>

<p><a href="https://i.stack.imgur.com/wpvBx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wpvBx.png" alt="enter image description here"></a></p>

<p>this is the piece of code where there error seems to be happening.</p>

<pre><code>#define  ADV_INTERVAL_MIN_MS  50
#define  ADV_INTERVAL_MAX_MS  100

void setConnectable(void)
{
  tBleStatus ret;

  const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME, 'B', 'l', 'u', 'e', 'N', 'R', 'G'};

  hci_le_set_scan_resp_data(0, NULL);
  PRINTF("General Discoverable Mode.\n");

  ret = aci_gap_set_discoverable(ADV_IND,
                                 (ADV_INTERVAL_MIN_MS * 1000) / 625, (ADV_INTERVAL_MAX_MS * 1000) / 625,
                                 STATIC_RANDOM_ADDR, NO_WHITE_LIST_USE,
                                 sizeof(local_name), local_name, 0, NULL, 0, 0);

  if (ret != BLE_STATUS_SUCCESS)
    PRINTF("%d\n", (uint8_t)ret);

}
</code></pre>
 7508: <p>You can specify the type of a number using suffixes such as <code>L</code>, <code>LL</code>,
<code>UL</code> and such. If you don't specify the type this way, all integers that
are small enough to fit in an <code>int</code> will be of type <code>int</code>. When you
write</p>

<pre class="lang-cpp prettyprint-override"><code>ADV_INTERVAL_MIN_MS * 1000
</code></pre>

<p>it gets expanded by the preprocessor to</p>

<pre class="lang-cpp prettyprint-override"><code>50 * 1000
</code></pre>

<p>Since both arguments are of type <code>int</code>, the compiler will use this type
to compute the result. However, the result is 50,000, and on 16-bit
systems the largest number that can fit in an <code>int</code> is 32,767, thus the
overflow.</p>

<p>As suggested by Majenko, the simple solution is to add the <code>L</code> suffix
(for <code>long</code>) to either operand. The compiler will then do the
arithmetics using the <code>long</code> data type.</p>
