Dynamically determine the inf and nan values. Should fix #14.