How to do floor division with negative numbers ?

Правка en1, от maybesomeone, 2022-09-18 19:33:03

like we do ceil division like this

int64_t ceil_div(int64_t a, int64_t b) {
    return a / b + ((a ^ b) > 0 && a % b != 0);
}

how to do floor division with negative numbers also.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский maybesomeone 2022-09-18 19:33:03 252 Initial revision (published)