Std :: numeric_limits <T> :: epsilon () for integrals
I do not have good links to std::numeric_limits<T> , but sites on the net say that std::numeric_limits<T>::epsilon() will return the difference between 1 and the smallest number after it. As far as I know about int , the next number after 1 is 2 , so epsilon should be 1 . But it is 0 (Linux, g ++ 4.4.5). What are the reasons for this?
I know that in practice epsilon() is only useful for floating point types, I'm just nitpicking.
The standard says ([numeric.limits.members])
The value for all floating point types.
The standard also says ([numerical. Special])
many values should be meaningful only under certain conditions (e.g. epsilon () only makes sense if is_integer is false). Any value that is not “significant” must be 0 or false.
Since the value is not “significant”, a value of 0 is required by the standard as an indication that it is not a significant value.