added clamp in double precision