EnglishGermanFrenchRussianPolishItalianSpanish
Log inRegister
 
[Lib] Exact division (using modular arithmatic)
Post new topic Reply to topic
View previous topic :: View next topic
Author Message
Osiris_sam





Joined: 24 Aug 2006
Posts: 422 on topic
Location: UK
Thank you for registering your game
PostPosted: Thu, 23. Jul 09, 13:44    Post subject: [Lib] Exact division (using modular arithmatic) Reply with quote Print

Exact division
Link

Usage:
Input:
-> 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)

have fun,
sam


_________________

my scripts: TC:HQ Management and upgrade framework
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic Reply to topic
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Control Panel
Login Data
The time now is Fri, 20. Oct 17, 14:23

All times are GMT + 2 Hours


Board Security

Copyright © EGOSOFT 1989-2017
Powered by phpBB © 2001, 2005 phpBB Group
Template created by Avatar & BurnIt!
Debug: page generation = 0.09485 seconds, sql queries = 15