Erin's equation

From Bacliff Exploration Society
Revision as of 09:22, 20 October 2015 by Giantsquid (talk | contribs) (Created page with "'''Erin's equation''' is a mathematical function which computes the number that is the same order of magnitude as a given number, but with only one significant digit. ==Pytho...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Erin's equation is a mathematical function which computes the number that is the same order of magnitude as a given number, but with only one significant digit.

Python sourcecode

def erin(x):
    from math import *
    t = pow(10, floor(log10(x)))
    return t * floor(x/t)

Example

erin(9876.54321) = 9000.0

See also