# Smallest unit in memory

**URL:** <https://community.particle.io/t/smallest-unit-in-memory/3882>\
**Category:** uncategorized\
**Created:** [April 12, 2014, 7:39am UTC](https://community.particle.io/t/smallest-unit-in-memory/3882 "2014-04-12T07:39:55Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![psb777](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/psb777/32/934_2.png) [@psb777](https://community.particle.io/u/psb777)\
**Post date:** [April 12, 2014, 9:29am UTC](https://community.particle.io/t/smallest-unit-in-memory/3882/5 "2014-04-12T09:29:10Z")

</div>

This:

```
char a, b; // 8 bits each
short int c, d; // 16 bits each
short int aC[2], aD[2]; // 32 bits each
int e, f; // 32 bits each
long g, h; // 32 bits each
char arrayA[3], arrayB[3]; // 24 bits each
char arrayC[4], arrayD[4]; // 32 bits each

char sbuf[80];

void setup() {
  sprintf( sbuf, "%s", __TIME__ );
  Spark.publish( "minalloc", sbuf);
  
  sprintf( sbuf, "chars %u %u - shorts %u %u", (char *)&a, (char *)&b, (char *)&c, (char *)&d);
  Spark.publish( "minalloc", sbuf);
  sprintf( sbuf, "ints %u %u - longs %u %u", (char *)&e, (char *)&f, (char *)&g, (char *)&h);
  Spark.publish( "minalloc", sbuf);
  sprintf( sbuf, "2shorts %u %u - 3chars %u %u", (char *)&aC, (char*)&aD, (char *)arrayA, (char *)arrayB);
  Spark.publish( "minalloc", sbuf);
  
  delay(3000); // publish delay

  sprintf( sbuf, "%u %u", (unsigned long)&b-(unsigned long)&a, (unsigned long)&d-(unsigned long)&c);
  Spark.publish( "minalloc", sbuf);
  sprintf( sbuf, "%u %u", (unsigned long)&f-(unsigned long)&e, (unsigned long)&h-(unsigned long)&g);
  Spark.publish( "minalloc", sbuf);
  sprintf( sbuf, "%u %u", (unsigned long)aD-(unsigned long)aC, (unsigned long)arrayB-(unsigned long)arrayA);
  Spark.publish( "minalloc", sbuf);
}

void loop() {
    delay(1000);
}

```

renders this:

```
09:25:04
chars 536873564 536873565 - shorts 536873566 536873568
ints 536873572 536873576 - longs 536873580 536873584
2shorts 536873588 536873592 - 3chars 536873596 536873599
1 2
4 4
4 3

```

---

_[View the full topic](https://community.particle.io/t/smallest-unit-in-memory/3882)._
