How to get off a minecart unharmed

In Minecraft, when I exit a minecart, I often lose half a heart (sometimes even more). But occasionally I don't get harmed. I wasn't able to find a rule, what to do to exit the cart unharmed ... is there a specific point to look at? Or something to do?


If there is only one block of headroom above the cart, the player will take half a heart of damage as he bangs his head on the ceiling.