X / (divisor || 1).
% cat >division.c <<EOF #include <stdio.h> int main(void) { printf("1/0 = %d\n", 1 / (0 || 1)); printf("1/2 = %d\n", 1 / (2 || 1)); printf("1.0/0 = %f\n", 1.0 / (0 || 1)); printf("1.0/2 = %f\n", 1.0 / (2 || 1)); } % gcc -Wall -o divison divison.c % ./divison 1/0 = 1 1/2 = 1 1.0/0 = 1.000000 1.0/2 = 1.000000
% python3 >>> 1 / (0 or 1) 1 >>> 1. / (0 or 1) 1.0 >>> 1 / (0 or 1) 1 >>> 1. / (2 or 1) 0.5 % python3 >>> 1 / (0 or 1) 1.0 >>> 1 / (2 or 1) 0.5
x / (divisor ?: 1)
C doesn't have booleans and treat them as integers 0 or 1, it can do the math and will always return 1.
https://en.cppreference.com/w/cpp/language/implicit_conversi... (under "Integral promotion")
And C has a boolean type as of C99.