Rev 491 | Rev 493 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 491 | Rev 492 | ||
---|---|---|---|
Line 121... | Line 121... | ||
121 | else q = -q; |
121 | else q = -q; |
122 | } |
122 | } |
123 | else if( x < 0) q = 4*((1<<15)-(1<<13)) - q; |
123 | else if( x < 0) q = 4*((1<<15)-(1<<13)) - q; |
124 | return(q); |
124 | return(q); |
125 | } |
125 | } |
- | 126 | ||
- | 127 | ||
- | 128 | ||
- | 129 | // retuns the largest integer whose square is less than or equal to the |
|
- | 130 | u32 isqrt(u32 value) |
|
- | 131 | { |
|
- | 132 | u32 rem = 0, root =0, idx; |
|
- | 133 | ||
- | 134 | for(idx = 0; idx < 16; idx++) |
|
- | 135 | { |
|
- | 136 | root <<= 1; |
|
- | 137 | ||
- | 138 | rem = ((rem << 2) + (value >> 30)); |
|
- | 139 | value <<= 2; |
|
- | 140 | root++; |
|
- | 141 | if(root <= rem) |
|
- | 142 | { |
|
- | 143 | rem -= root; |
|
- | 144 | root++; |
|
- | 145 | } |
|
- | 146 | else |
|
- | 147 | { |
|
- | 148 | root--; |
|
- | 149 | } |
|
- | 150 | } |
|
- | 151 | return(root >> 1); |
|
- | 152 | } |
|
- | 153 |