utility methods for best-effort datatype casting