In my opinion it's somewhat confusing that the handle returned by handle() is of type var, while the return value actually represents a long integer.

Converting handles into other data types doesn't seem to work because of that.
E.g. (long)handle(ent) returns a wrong value. Additionally handles can't be converted into STRINGs via str_for_num() and they can't be written into files via file_var_write(). In all cases the converted handles read as "65536" instead.

The best workaround I've found so far is using memcpy() to copy the var handle into a long. Then it's also possible to convert it into a STRING using str_for_int().

Perhaps the manual should give a hint about this.