Skip to content

Commit bea6a5b

Browse files
author
Ricky Cheung
committed
avr: Switch to standard snprintf() to convert unsigned int to char
The original ultoa() function is widely supported by Arduino boards, however some other boards with custom BSPs may not include this function, as it is non-standard / non-ISO. Switch to a more generally available snprintf() call to improve compatibility. This change also provide a slight speed boost to some boards (e.g. RP2040) that may have a bad implementation. Signed-off-by: Ricky Cheung <[email protected]>
1 parent 99ac8d5 commit bea6a5b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Arduino_Code/Arduino_Code.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ uint32_t ducos1a() {
123123
uint32_t const maxNonce = job->difficulty * 100 + 1;
124124
char nonceStr[10 + 1];
125125
for (uint32_t nonce = 0; nonce < maxNonce; nonce++) {
126-
ultoa(nonce, nonceStr, 10);
126+
snprintf(nonceStr, 10, "%lu", nonce);
127127

128128
uint8_t const * hash_bytes = duco_hash_try_nonce(&hash, nonceStr);
129129
if (memcmp(hash_bytes, target, SHA1_HASH_LEN) == 0) {

0 commit comments

Comments
 (0)