-
-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using size_t limits max number to 2^32. #739
Conversation
we could be asked to print a uint64 (for example, from SD.totalGytes()).
original
your code
|
Noted. |
With |
Using size_t would have overflowed at (approx) 2^28. But with a uint64_t the limit is going to be up in the Exbi range (2^60).
… little more system memory.
don't index beyond the end of the array.
Reworked the code to use an array of suffixes and reduce the number of snprintf_P statements. This means if TiB or others are needed, they just need to be added to the array. |
Thanks, I did a bit more refactoring to make the code even more universal, and added Terabytes. cc1d6d9 |
When dealing with SD cards we could be asked to print a uint64 (for example, from SD.totalGytes()).
This attempt to handle the very large numbers that might be expected from an SD card.
Yes, there is a bit of ugliness from recasting to a uint32 before calling the snprintf function, but this avoids implicit casts where data could be truncated.