It’s generally not good form to refer people to other unresolved questions in order to answer your question. Don’t make people do work in order to understand what you’re asking. See also: Please read: make it easier to help you
It’s pretty common in programming languages for booleans true and false to be represented by 1 and 0 respectively. In python, they are literally the same (1 == True). In Julia, they’re not the same thing, but you can convert a Bool into a number as you’ve shown. To reiterate:
As others have explained it’s an established (and quite useful) convention in programming languages, but also in mathematics, to associate true and false with the values 1 and 0. I believe what you rather want to ask is why the implementation of inv chooses to make use of this convention.
Afaik, the general convention for number types is that T(true) == one(T) and T(false) == zero(T), i.e.~you should get the neutral elements for addition and multiplication in your field / ring / approximate field, and true * x == x, and false * x == zero(typeof(x)).
Note the hard zero: E.g. 0*Inf is NaN, but false*Inf is 0.0.