??? 10/05/08 12:22 Read: times |
#158849 - Fixed-point or integer Responding to: ???'s previous message |
The supplied algorithm works just as well with integers or fixed-point.
An attempt with unsigned data type and the number 12714 gives: 0 12714 6357 1 6357 3179 2 3179 1591 3 1591 799 4 799 407 5 407 219 6 219 138 7 138 115 8 115 112 9 112 112 sqrt 12714 = 112 (112.756)When integers are used, the answer will be truncated. It may be an idea to also try to take the answer+1 and square to decide which two integers will be closest. An attempt at fixed point can also be done. Sqrt of 2.000000 results in: 0 2000000 1000000 1 1000000 500001 2 500001 250002 3 250002 125004 4 125004 62509 5 62509 31270 6 31270 15666 7 15666 7896 8 7896 4074 9 4074 2282 10 2282 1579 11 1579 1422 12 1422 1414 13 1414 1414 14 1414 1414 sqrt 2.000000 = 1.414 (1.41421)The problem with fixed point is that the evaluation must be done with at least twice as many decimals as the expected end result, since a square doubles the number of digits. In the end, it will be up to OP to figure out if the problem was to evaluate the square root of 24-bit integers, or if it was 24-bit fixed-point numbers or possibly tiny 24-bit floating-point numbers. I kind of assume that this is a school exercise, in which ase the optional conversion to fixed point and the rewrite into assembler will be required steps before the solution is turned in. |
Topic | Author | Date |
code library for 24 bit sqare root in asm | 01/01/70 00:00 | |
So, what have you tried ? | 01/01/70 00:00 | |
Is the " subject problem" homework? | 01/01/70 00:00 | |
code library for 24 bit sqare root in asm | 01/01/70 00:00 | |
Algorithm is important | 01/01/70 00:00 | |
thinking | 01/01/70 00:00 | |
Integer? | 01/01/70 00:00 | |
Fixed-point or integer | 01/01/70 00:00 | |
Issues with Newton-approximation | 01/01/70 00:00 | |
Excellent link | 01/01/70 00:00 | |
fixed point or integer method of Per Westermark | 01/01/70 00:00 |