Use a 10^6 precision as in OSRM.
Small utility to encode/decode with or without elevation