Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • Integer multiplication is OK on Arduinos, as the ATmegas have a hardware multiplier. But note that some Arduino-compatible boards (Trinket, Digispark, ...) are based on ATtinies, which do not have such multiplier. Commented Jan 25, 2018 at 12:06
  • 2
    Arduino libraries relying on C++11 are not that uncommon. Also, a lot of STL containers can be used without dynamic memory allocation. Nothing stops you from creating an std::vector on stack. Commented Jan 25, 2018 at 12:43
  • @EdgarBonet Isn't that only an 8-bit x 8-bit multiplier though? Technically an 8-bit value is not an integer. ;) Commented Jan 25, 2018 at 12:49
  • 2
    1. Yes, it's a 8×8→16 bit multiplier. It is used by the compiler to implement all multiplications far more efficiently than a bitwise shift-and-add. Multiplying two ints requires only three 8×8→16 multiplications (two bytes of flash and two CPU cycles each) and a few additions. 2. Technically, both int8_t and an uint8_t are 8-bit integer types. But this is completely unrelated to my first comment. Commented Jan 25, 2018 at 13:06
  • @EdgarBonet Error on my part - it's an integer, just not an "int". :) Commented Jan 25, 2018 at 13:07