We propose a scheme for an all-optical comparator which embeds a nonlinear fiber ring resonator in a Mach–Zehnder configuration. Such a resonator accumulates the circulating power of the light traversing the ring, so that the effective nonlinear phase shift in fiber can be significantly enhanced. Numerical results demonstrate that with appropriate choice of the parameters of the Mach–Zehnder configuration and the power of the probe light, the all-optical comparator can exhibit an excellent step-like transfer function. Simultaneously, the configuration reduces the switching threshold by 3 or more orders of magnitude to the level of milliwatt when conventional highly nonlinear fibers are adopted. In addition, our simulations show that this all-optical threshold comparator also has a multiperiodic transfer characteristic and thus may be used to construct multibit analog-to-digital convertors.