The demagnetizing factor N is of both conceptual interest and practical importance. Considering localized magnetic moments on a lattice, we show that for nonellipsoidal samples, N depends on the spin dimensionality (Ising, XY, or Heisenberg) and orientation, as well as the sample shape and susceptibility. The generality of this result is demonstrated by means of a recursive analytic calculation as well as detailed Monte Carlo simulations of realistic model spin Hamiltonians. As an important check and application, we also make an accurate experimental determination of N for a representative collective paramagnet (i.e., the Dy 2 Ti 2 O 7 spin ice compound) and show that the temperature dependence of the experimentally determined N agrees closely with our theoretical calculations. Our conclusion is that the well-established practice of approximating the true sample shape with "corresponding ellipsoids" for systems with long-range interactions will in many cases overlook important effects stemming from the microscopic aspects of the system under consideration.