# How to use coder.unroll in a while loop

1 view (last 30 days)

Show older comments

Life is Wonderful
on 16 Aug 2022

Commented: Life is Wonderful
on 16 Aug 2022

Hi

I'm looking for a sample code of how to use "coder. unroll" in a while loop. I intend to perform a division operation and want to unroll the loop if I achieve the required accuracy level.

For example,

format long g

a = (4);

b = (6);

T = numerictype('Signed', true,...

'WordLength', 64,...

'FractionLength', 60);

quotient = divide(T,a,b)

and I want to stop the division process when a certain fractional bit accuracy, say 0.6667, is reached.

##### 0 Comments

### Accepted Answer

Walter Roberson
on 16 Aug 2022

##### 6 Comments

Walter Roberson
on 16 Aug 2022

I seem to recall that the CORDIC division algorithm stops early if it reaches its goal.

### More Answers (0)

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!