Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
getMaxWordLength().... Ben Bacarisse wins!
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Keith Thompson" data-source="post: 5165599"><p>Some quibbles (none of which are meant to detract from the main point):</p><p></p><p>Surely upower(1, -1) should be 1, not 0. upower(0, -1) (or with any</p><p>negative exponent) is an error; it's not clear how that should be</p><p>handled. You might make n an unsigned int, since negative exponents</p><p>aren't particularly useful for an integer power function.</p><p></p><p>In the last return statement, (n-1)/2 could be written as n/2, since n</p><p>is odd and integer division truncates anyway. I might put the</p><p>multiplication by a at the beginning of the expression, just to make it</p><p>stand out more:</p><p></p><p>return a * upower(a*a, n/2);</p></blockquote><p></p>
[QUOTE="Keith Thompson, post: 5165599"] Some quibbles (none of which are meant to detract from the main point): Surely upower(1, -1) should be 1, not 0. upower(0, -1) (or with any negative exponent) is an error; it's not clear how that should be handled. You might make n an unsigned int, since negative exponents aren't particularly useful for an integer power function. In the last return statement, (n-1)/2 could be written as n/2, since n is odd and integer division truncates anyway. I might put the multiplication by a at the beginning of the expression, just to make it stand out more: return a * upower(a*a, n/2); [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
getMaxWordLength().... Ben Bacarisse wins!
Top