Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



> 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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: