function(to_hex DEC HEX)
	while(DEC GREATER 0)
		math(EXPR _val "${DEC} % 16")
		math(EXPR DEC "${DEC} / 16")
		if(_val EQUAL 10)
			set(_val "a")
		elseif(_val EQUAL 11)
			set(_val "b")
		elseif(_val EQUAL 12)
			set(_val "c")
		elseif(_val EQUAL 13)
			set(_val "d")
		elseif(_val EQUAL 14)
			set(_val "e")
		elseif(_val EQUAL 15)
			set(_val "f")
		endif()
		set(_res "${_val}${_res}")
	endwhile()
	set(${HEX} "0x${_res}" PARENT_SCOPE)
endfunction()
