adafruit / Adafruit_FRAM_SPI

Driver for Adafruit's SPI-Based FRAM Breakouts
Other
34 stars 30 forks source link

int multiplication results in overflow #22

Closed lwestfall closed 3 years ago

lwestfall commented 3 years ago

Hello,

On the ATmega boards (Uno, etc) these multiplications are evaluated as 16-bit int multiplication which results in an overflow. Appending L to either of the operands will evaluate these as longs, which fixes the issue for these boards. I can submit a PR if you'd like.

https://github.com/adafruit/Adafruit_FRAM_SPI/blob/5921d08d4699f1576879e557c8bf571661216a7f/Adafruit_FRAM_SPI.cpp#L46-L51

hathach commented 3 years ago

Yeah, please do a PR with UL suffix if you have time. Thank you for raising this