Divide an integer by 3
How to perform division by 3 of an integer number in SigmaStudio?
Thank you in advance!
Omar
integer divide
Hello Omar,
The most economical way to divide by a constant number (such as 3) is to multiply by its reciprocal. An example running on the ADAU1701 is shown below.
Here the input integer is 27. To divide by 3, we can multiply by 0.3334. Because the multiplication only rounds down, increasing the last digit of the multiplier by one helps provide a correct result. The ADAU1701's readback register is only 24 bits wide, truncating the lowest 4 bits -- thus we need to shift 4 bits to the left (multiply by 16) to correctly readback an integer number.
Best regards,
Bob
Embarassing how simple it was.
Thanks Bob!
Please log in to reply.

