Python, measuring distance using ray_cast I have one problem I need help with.

I'm trying to measure a distance between the origin point and hit point using ray_cast.
Is it possible or do I have to use another tool?

ray_cast loc[2] always return 1.0 or -1.0

cb = bpy.data.objects['Cube']
src = bpy.data.objects['src']
dst = bpy.data.objects['dst']

mw = cb.matrix_world
mwi = mw.inverted()

origin = mwi * src.matrix_world.translation
dest = mwi * dst.matrix_world.translation
direction = (dest - origin).normalized()

hit, loc, norm, face = cb.ray_cast(origin, direction)




Thank you for your answer.
The location of hit loc is the local coordinate on the cube face that the ray hits.  

Its local distance from origin

(origin - loc).length


its global distance from origin

(mw * loc - src.matrix_world.translation).length


With no rotation or scale applied all local coordinates  on default cube are either 1 or -1.  The top and bottom faces are the planes z = 1 and z = -1 respectively.