Last active
October 7, 2021 17:10
-
-
Save withs/dcf1932953d11c9036ef9826eac9eca4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "cstdint" | |
uint16_t intLen(uint32_t forInt) { | |
uint64_t factor = 1; | |
uint16_t intLen; | |
for ( intLen = 0 ; (forInt / factor) != 0 ; intLen++ ) { | |
factor *= 10; | |
} | |
return intLen; | |
} | |
uint32_t intReverse(uint32_t forInt) { | |
uint8_t factor = 1; | |
uint32_t res = 0; | |
for ( uint16_t it = 0 ; forInt != 0 ; it++ ) { | |
res = (res * factor) + (forInt % 10); | |
forInt = forInt / 10; | |
if ( it == 0 ) | |
factor = 10; | |
} | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment