Correct code to get a value between 0 and 1