basil4j 1 Posted March 19, 2014 Share Posted March 19, 2014 Hi All, Hope no-one minds me bombarding the forums with these n00b questions I am writing the math for my rocket altimeter project and have some questions regarding the best way to do it. Im using CCS and MSP430FR5739 which has hardware multiply, and I have included the MSP430_math routines Lets say I need to perform the following equation (as an example) P = (D1 * SENS / 2 - OFF) / 2 D1 = unsigned long SENSE = signed long OFF = signed long Obvious optimisations aside (e.g. D1 / 2 before the FP mult to save an FP div...), would it give me faster code to break it into parts (not as concerned about code size) P = SENS / 2 P = P * D1 P = P - OFF P = P / 2 or leave it as a single equation as in the example? Is it faster to divide or multiply? This example is probably a bad one since div2 would be nice and easy, but lets assume I need to divide by 200 and end up with a floating point result. Would I be better off multiplying by 0.005 instead? I have enabled the hardware multiply. What is the trade off between 16 and 32 bit mult? This next one isnt really MSP430 or C related, but I still need help Math has never been my strong point... If n = 5.257, is x ^ (1/n) the same as x ^ (0.1902225)? Or will I need to use logarithmic math? <---This bit rings a bell from high school... 0.1902225 being the result of performing 1/n Thanks again in advance! Quote Link to post Share on other sites
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.