s - (Optional) shall be of type real and not equal to zero.

Return value

The return value is of the same type as x. If s is positive, nearest returns the processor-representable number greater than x and nearest to it. If s is negative, nearest returns the processor-representable number smaller than x and nearest to it.

Example

program test_nearestreal::x,yx=nearest(42.0,1.0)y=nearest(42.0,-1.0)write(*,"(3(G20.15))")x,y,x-yendprogram test_nearest