[Numpy-discussion] common significant diigits
Wed Sep 15 14:41:41 CDT 2010
On Wed, Sep 15, 2010 at 2:34 PM, Benjamin Root <firstname.lastname@example.org> wrote:
> I am trying to solve a problem in matplotlib where I would have an array of
> floating point numbers and I want to quickly determine what is the closest
> common offset to a power of 10. In other words, if given:
> [12373.43, 12375.89, 12370.18],
> I would want returned something like either 12370.0, or the lowest common
> order of magnitude (in this case, 10).
> Is there some sort of neat math/numpy trick to figure this out? I already
> have a brute-force method with a while loop, but I am looking for something
> a little bit more elegant.
> Ben Root
> NumPy-Discussion mailing list
Probably not being very fail-safe here is my first guess:
a = np.array([12373.43, 12375.89, 12370.18])
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion