Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 393 Bytes

README.md

File metadata and controls

19 lines (16 loc) · 393 Bytes

2.36

/* Determine whether arguments can be multiplied without overflow */
int tmult_ok(int32_t x, int32_t y) {
    int64_t p = x * y;
    return !((p >= ((1<<31) - 1)) || (p < 1<<31)) ;
}

or other solution:

/* Determine whether arguments can be multiplied without overflow */
int tmult_ok(int32_t x, int32_t y) {
    int64_t p = x * y;
    return p == (int32_t)p;
}