not (A or B) = (not A) and (not B)<\/code><\/p><\/blockquote>\nThis means the result of the or<\/code> operation is the negation of the and<\/code> operation between the negations of --k<\/code> and --i<\/code>. Putting this into CSS, we have:<\/p>\n--or: calc(1 - (1 - var(--k))*(1 - var(--i)))<\/code><\/pre>\nFor each scenario, we get:<\/p>\n
\n- for
--k: 0<\/code>, --i: 0<\/code>, we have that --or<\/code> is 0<\/code> (1 - (1 - 0)*(1 - 0) = 1 - 1*1 = 1 - 1<\/code>)<\/li>\n- for
--k: 0<\/code>, --i: 1<\/code>, we have that --or<\/code> is 1<\/code> (1 - (1 - 0)*(1 - 1) = 1 - 1*0 = 1 - 0<\/code>)<\/li>\n- for
--k: 1<\/code>, --i: 0<\/code>, we have that --or<\/code> is 1<\/code> (1 - (1 - 1)*(1 - 0) = 1 - 0*1 = 1 - 0<\/code>)<\/li>\n- for
--k: 1<\/code>, --i: 1<\/code>, we have that --or<\/code> is 1<\/code> (1 - (1 - 1)*(1 - 1) = 1 - 0*0 = 1 - 0<\/code>)<\/li>\n<\/ul>\nnor<\/code><\/h4>\nSince nor<\/code> is not or<\/code>, we have:<\/p>\n--nor: calc((1 - var(--k))*(1 - var(--i)))<\/code><\/pre>\nFor each of our four possible scenarios, we get:<\/p>\n
\n- for
--k: 0<\/code>, --i: 0<\/code>, we have that --nor<\/code> is 1<\/code> ((1 - 0)*(1 - 0) = 1*1<\/code>)<\/li>\n- for
--k: 0<\/code>, --i: 1<\/code>, we have that --nor<\/code> is 0<\/code> ((1 - 0)*(1 - 1) = 1*0<\/code>)<\/li>\n- for
--k: 1<\/code>, --i: 0<\/code>, we have that --nor<\/code> is 0<\/code> ((1 - 1)*(1 - 0) = 0*1<\/code>)<\/li>\n- for
--k: 1<\/code>, --i: 1<\/code>, we have that --nor<\/code> is 0<\/code> ((1 - 1)*(1 - 1) = 0*0<\/code>)<\/li>\n<\/ul>\nxor<\/code><\/h4>\nThe result of the xor<\/code> operation is 1<\/code> when one of the two operands is 1<\/code> and the other one is 0<\/code>. This feels trickier at first, but, if we think this means the two operands need to be different for the result to be 1<\/code> (otherwise it’s 0<\/code>), we stumble upon the right arithmetic operation to use inside calc()<\/code>: subtraction!<\/p>\nIf --k<\/code> and --i<\/code> are equal, then subtracting --i<\/code> from --k<\/code> gives us 0<\/code>. Otherwise, if we have --k: 0<\/code>, --i: 1<\/code>, the result of the same subtraction is -1<\/code>; if we have --k: 1<\/code>, --i: 0<\/code>, the result is 1<\/code>.<\/p>\nClose, but not quite! We get the result we want in three out of four scenarios, but we need to get 1<\/code>, not -1<\/code> in the --k: 0<\/code>, --i: 1<\/code> scenario.<\/p>\nHowever, one thing that -1<\/code>, 0<\/code> and 1<\/code> have in common is that multiplying them with themselves gives us their absolute value (which is 1<\/code> for both -1<\/code> and 1<\/code>). So the actual solution is to multiply this difference with itself:<\/p>\n--xor: calc((var(--k) - var(--i))*(var(--k) - var(--i)))<\/code><\/pre>\nTesting each of our four possible scenarios, we have:<\/p>\n
\n- for
--k: 0<\/code>, --i: 0<\/code>, we have that --xor<\/code> is 0<\/code> ((0 - 0)*(0 - 0) = 0*0<\/code>)<\/li>\n