Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
syntax:ccmd:c_for [2013/07/15 03:50] ormaaj [Bits analyzer] When performing recursive arithmetic it's more efficient to move an assignment out of the recursive expression so it's tail-recursive. |
syntax:ccmd:c_for [2013/07/15 03:56] ormaaj [Bugs] |
||
---|---|---|---|
Line 140: | Line 140: | ||
Why that one begins at 128 (highest value, on the left) and not 1 (lowest value, on the right)? It's easier to print from left to right... | Why that one begins at 128 (highest value, on the left) and not 1 (lowest value, on the right)? It's easier to print from left to right... | ||
- | We arrive at 128 for ''n'' through the recursive arithmetic expression stored in ''x'', which calculates the next-greatest power of 2 after ''m''. To show that it works, we use ksh93 to double-check the answer, because it has a built-in feature for ''printf'' to print a decimal representation of any number in an arbitrary base (up to 64 bits). Very few languages have that ability built-in, even things like Python. | + | We arrive at 128 for ''n'' through the recursive arithmetic expression stored in ''x'', which calculates the next-greatest power of 2 after ''m''. To show that it works, we use ksh93 to double-check the answer, because it has a built-in feature for ''printf'' to print a representation of any number in an arbitrary base (up to 64). Very few languages have that ability built-in, even things like Python. |
==== Up, down, up, down... ==== | ==== Up, down, up, down... ==== | ||
Line 180: | Line 180: | ||
===== Bugs ===== | ===== Bugs ===== | ||
- | * //Fixed in git for >4.2//. <del>There appears to be a bug as of Bash 4.2p10 in which command lists can't be distinguished from the for loop's arithmetic argument delimiter (both semicolons), so command substitutions within the C-style for loop expression can't contain more than one command.</del> | + | * //Fixed in 4.3//. <del>There appears to be a bug as of Bash 4.2p10 in which command lists can't be distinguished from the for loop's arithmetic argument delimiter (both semicolons), so command substitutions within the C-style for loop expression can't contain more than one command.</del> |
===== See also ===== | ===== See also ===== |