Joined: 24 Aug 2006
Posts: 422 on topic
|Posted: Thu, 23. Jul 09, 13:44 Post subject: [Lib] Exact division (using modular arithmatic)
-> number ~ the number you want to divide
-> number to divide by ~ the number you want to divide by (must be non 0)
-> Accuracy ~ number of decimal points to calculate to. setting this to 0 will return a number, setting to 1, 2, 3 or 4 will return that number of decimal points
this script will return the answer in string form. i was going to write string arithmatic libraries, but while testing, it kept freezing and idk why.
Theory: for anyone interested
this script calculates the answer in two parts, as an integer, and as a decimal.
the interger componnet is calculated by the normal method.
the decimal component is calculated by finding the remainder when x is divided by y, multiplying that by the accuracy coefficient, and then dividing by y. (using the mod function)
my scripts: TC:HQ Management and upgrade framework