I'm trying to calculate the height of an entity relative to the terrain. Pretty easy you'd think, but there is a problem.
How can this code :
Generate this result? (actual screenshot of this exact code)

Shouldn't it be 3.5 ? There is probably a very logical explenation for this, but I don't understand.
How can this code :
py#=entityy(pos) ty#=terrainy(e_terrain\terrain,entityx(pos),0,entityz(pos)) text 10,160,py+" - "+ ty + " = " + (py-ty)
Generate this result? (actual screenshot of this exact code)

Shouldn't it be 3.5 ? There is probably a very logical explenation for this, but I don't understand.