Sign in to follow this  
Followers 0
Mat

Advanced rounding

5 posts in this topic

#1 ·  Posted (edited)

I stumbled across a website the other day that said only one interesting thing... That you round -1.5 to -2. I have always been taught this should in fact be -1, so I asked wikipedia, found out there is actually about 8 different ways to resolve tie breaks. So I did a lot of research into rounding, and made this function.

The functions parameters are a bit too complex to be all listed here, alongsside other stuff I need to mention, so I made a simple web page for it.

Download Link: http://code.google.com/p/m-a-t/downloads/detail?name=Advanced%20Rounding.zip

Info Page: http://code.google.com/p/m-a-t/wiki/Rounding

On the page is the download link as well as another link to a dialog I created that is pretty simple, but gives you all the options in a more usable way. I might release it as an actual program later, but its not particularly useful. Even If you have no need for either, it makes very interesting reading, and does teach you a lot about computing numbers and floats.

Mat

Edit: you know, I was kinda hoping someone MIGHT just be interested, but I've had 4 vistors to that page, with an interest span of... <10secs. Maybe it wasn't worth the bother.

Edited by Mat

Share this post


Link to post
Share on other sites



Hey Mat, that was very interesting to read! : ) I never knew there were different types of rounding either, but you explained it very simple.

Share this post


Link to post
Share on other sites

Thanks manadar, good to see someone read it! Its explained simple becouse I understand it simple. I should probably do this on the page; a list of my sources:

1) Wikipedia

2) Rounding and truncating functions (PDF)

^^ The above was very helpful, and is aimed at programming.

3) DIY Calculator

Wikipedia was the first thing I found (obviously!), the other two I found in the reference section there. The PDF is a VERY interesting read, and explains functions such as: Mod, Int, Round, Floor, Ceiling. It also gives other ideas like getting the fractional part etc.

Mat

Share this post


Link to post
Share on other sites

Thanks again manadar! This was written as a function for my minicalculator script (just passed 2000 lines), and there it is proving incredibly useful!!!

The other thing I'm thinking of is combining this with some bigint functions... creating myself a kind of "pure maths" udf. Shouldn't be too hard... I could add some other functions i've done like my root function.

Why maths excites me I will never know.

Mat

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0