3 ms·
I like the idea of your first try, but it's not guaranteed to work on all implementations, even with the type promotion fixed. The problem is that the C standar
by chowells 8y ago
I like the idea of your first try, but it's not guaranteed to work on all implementations, even with the type promotion fixed. The problem is that the C standard doesn't specify a maximum size for int. It could be a 128 bit type.
"Portable C" doesn't exist.
- jcelerier 8y ago> I like the idea of your first try, but it's not guaranteed to work on all implementations, in C++ you'd just add static_assert(sizeof(int) < sizeof(int64_t), "fix your types"); to be safe about this