Several computational problems in science and engineering are stringent enough that maintaining positivity of density and pressure can become a problem. We build on the realization that positivity can be lost within a zone when reconstruction is carried out in the zone. We present a multidimensional, self-adjusting strategy for enforcing the positivity of density and pressure in hydrodynamic and magnetohydrodynamic (MHD) simulations. The MHD case has never been addressed before, and the hydrodynamic case has never been presented in quite the same way as done here. The method examines the local flow to identify regions with strong shocks. The permitted range of densities and pressures is also obtained at each zone by examining neighboring zones. The range is expanded if the solution is free of strong shocks in order to accommodate higher order non-oscillatory reconstructions. The density and pressure are then brought into the permitted range. The method has also been extended to MHD. It is very efficient and should extend to discontinuous Galerkin methods as well as flows on unstructured meshes. [GRAPHICS] The method presented here does not degrade the order of accuracy for smooth flows. Via a stringent test suite, we document that our method works well on structured meshes for all orders of accuracy up to four. When the same test problems are run without the positivity preserving methods, one sees a very clear degradation in the results, highlighting the value of the present method. The results are compelling because realistic simulation of several difficult astrophysical and space physics problems requires the use of parameters that are similar to the ones in our test problems. In this work, weighted non-oscillatory reconstruction was applied to the conserved variables, i.e. we did not apply the reconstruction to the characteristic variables, which would have made the scheme more expensive. Yet, used in conjunction with the positivity preserving schemes presented here, the less expensive reconstruction works very well in two and three dimensions. The positivity preserving methods are easy to implement and inexpensive; they only increase the cost of reconstruction by a very small fraction. All these facts suggest that a self-adjusting positivity preserving algorithm is almost as important as non-linear hybridization in the design of robust, higher-order schemes. (C) 2012 Elsevier Inc. All rights reserved.