VaultBoss 310 Posted October 12, 2012 Report Share Posted October 12, 2012 Although I believe these should actually be implemented as core functions in UBot, there are some math functions that I missed when coding, such as INT (Integer), Round, etc... I decided to write one for my own use and to share with you guys here (please test it and see if I missed something?) So I started with a Round function, with two input parameters:first the number to be rounded second, the number of digits allowed as decimals in the resultThe code would have been simpler in most cases, but to cover some extremes and some particular instances and combos, it kinda... grew... lol It accepts Inputs with or without decimals and it will round up to 10 from 5 included, or down to 0 till 5 excluded. Examples:1.5 -> 1.5 with 1 digit,OR1.5 -> 2 with 0 digitsOR1.5 -> 1.50000 with 5 digits-----0.99 -> 1.0 with 1 digit,OR0.99 -> 1 with 0 digitsOR0.99 -> 1.00000 with 5 digits-----1.456 -> 1.46 with 2 digits,OR1.456 -> 1.5 with 1 digit,OR1.456 -> 2 with 0 digits,and so forth... The package contains actually 2 functions, where the Round Func calls the Round10 function repeatedly, so you need to copy both functions into your bots in order to work properly Here it is, feel free to use it in all your bots, even commercial, without any attribution, etc...It's just my way to thank this great community.(A LIKE might be nice though... ha, ha, ha...)Round-Function-V1.1.ubot 3 Quote Link to post Share on other sites
VaultBoss 310 Posted October 14, 2012 Author Report Share Posted October 14, 2012 I have noticed 3 types of various errors, 2 of them minor (happening in very rare situations) and one of them major (results were wrong when the first decimal(s) were zeros. I have corrected all 3 errors and tested more extensively. So far it looks like it finally works as expected, so I changed the library above to reflect the edits. ----- New Example:1.0456 -> 1.05 with 2 digits,OR1.0456 -> 1.0 with 1 digit,OR1.0456 -> 1 with 0 digits,OR1.0456 -> 1.046 with 3 digits,and so forth... ----- If you downloaded it before, please replace the old code with this new one.(re-attached to first post) Enjoy! Quote Link to post Share on other sites
anis 0 Posted September 15, 2013 Report Share Posted September 15, 2013 thanks for this function Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.