I assume it’s so that calculations including pi do not promote results more than required. Bool is the “smallest” number type. This is also why I(2) turns into a matrix of bools if you call Matrix on it.
That makes sense. In that case, one(pi) seems fine but sign() should probably have an extra method for ::AbstractIrrational to handle the fact that one(x) will not be large enough to hold -1.
this Bool matrix also looks awkward… maybe we should just use Int8 to be the “smallest” number type. I think Bool is stored with 1 byte anyways at the end of the day?
It’s not about the storage true requires to store, it’s mostly because usually promote(::Bool, ::T)::T, i.e. Bool is kind of the “neutral type” under promotion.
The idea behind AbstractIrrational is that the irrational constants can take on the type of the other numbers used in a calculation, so e.g. pi + 1.0 gives a Float64, pi + big"1.0" a BigFloat, pi + 1f0 a Float32, etc. Returning a Float64 in one(::AbstractIrrational) would defeat this, because it would convert any Float32 you add it to (or do any other arithmetic operation with) to a Float64 instead.