View Full Version : 32-bit math funcitons ...
njones
09-18-2009, 11:30 AM
I need the following 32-bit math functions, I'm going to write them unless anyone has already done them and is willing to share...
32-bit / 16-bit with 16-bit result and 16-bit remainder
16-bit X 16-bit multiply with 32-bit result
njones
09-23-2009, 12:43 PM
Ok, I simplified things to meet my requirements. I only need 14-bit X 14-bit unsigned multiply with 28-bit result and 28-bit by 14-bit unsigned divide. The code gets a little messy (and slower) dealing with more bits.
The attached 28/14 divide function is based on an algorithm that is intended for 31/15 bit unsigned divide, but I have limited it to the argument range I need and have tested.
These functions will take weeks or months to test 100% on the actual target system. My basic test code (also attached) does a scatter test, and a longer test checks the full range of inputs, but still does a scatter test of remainder. The long test is running now, but I don't know how long it will take.
Any suggestions to improve performance are welcome - I'm not a math whiz and I don't know the internal workings of the python runtime so I can't know which operations may have better performance.
Enjoy!
P.S. I think this code works, but no guarantees.
vBulletin® v3.8.0, Copyright ©2000-2012, Jelsoft Enterprises Ltd.