Do not comment out relevant code
// #include "int128_test_5.h", with the // removed, fails the compile with error: unknown type name 'uint128'
OP failed to test the header file.
Header is missing code guards and int128 definition.
Do not comment out relevant code
// #include "int128_test_5.h", with the // removed, fails the compile with error: unknown type name 'uint128'
OP failed to test the header file.
Use size_t for array sizing and indexing rather than int.
// char* u128toasc( char *s, int len, uint128 x )
char* u128toasc( char *s, size_t len, uint128 x )
Advanced: Consider leading with the size
uint128 asctou128( char *sThe below allows for more error checking.
// char* u128toasc( char *s, int len, uint128 x )
char* u128toasc(size_t len, char *s, uint128 x
// or using later compilers
char* u128toasc(size_t len, char s[len], uint128 x )
Minor: simplification
memmove( str, str + j, len - j );
return( str );
simpler as:
return memmove( str, str + j, len - j );
OP got lucky
What is the type and value of )( ~U128_MIN )?
int128 asctoi128( char s )
char u128toasc( char s, int len, uint128 x )
char i128toasc( char *s, int len, int128 x )~ is not operating on 128 bits.
#define U128_MIN 0
#define U128_MAX (uint128)( ~U128_MIN )