Let K be an expansion of either an ordered field (K, ), or a valued field (K, v). Given a definable set X ⊆ K m let C(X) be the ring of continuous definable functions from X to K. Under very mild assumptions on the geometry of X and on the structure K, in particular when K is o-minimal or P -minimal, or an expansion of a local field, we prove that the ring of integers Z is interpretable in C(X). If K is o-minimal and X is definably connected of pure dimension 2, then C(X) defines the subring Z. If K is P -minimal and X has no isolated points, then there is a discrete ring Z contained in K and naturally isomorphic to Z, such that the ring of functions f ∈ C(X) which take values in Z is definable in C(X).