Get your taxes done using TurboTax

Roughly speaking, if all your regular income is $40K and you are filing as single, we subtract your standard deduction of $14,600 to get taxable income of $25,400.  Then, the zero percent capital gains rate goes up to $47,150.  Since $47150-$25,400=$21,750, that means the first $21,750 of the gain is taxed at zero percent and the rest is taxed at 15%.