Retirement tax questions

Follow-up question: What do earnings in the traditional IRA count towards when determining the basis?

Is the formula to determine the taxable amount of the conversion:

(1-(after-tax contributions/total IRA value including earnings))*Roth conversion

or should the denominator not include the earnings?