Count in octal: Difference between revisions

Content added Content deleted
No edit summary
Line 1,730: Line 1,730:


We use arbitrary precision numbers, not because there's any likelihood that fixed width numbers would ever overflow, but to emphasize that this thing is going to have to be shut down by some mechanism outside the program.
We use arbitrary precision numbers, not because there's any likelihood that fixed width numbers would ever overflow, but to emphasize that this thing is going to have to be shut down by some mechanism outside the program.

That said... note that what we are doing here is counting using an internal representation and converting that to octal for display. If we instead wanted to add 1 to a value provided to us in octal and provide the result in octal, we might instead use <code>&gt;:</code> (add 1) and wrap it in <code>&amp;.(8&amp;#.)</code> (convert argument from octal and use inverse on result) with a list of digits representing our octal number. For example:

<lang J> >:&.(8&#.)7 6
7 7
>:&.(8&#.)7 7
1 0 0
>:&.(8&#.)1 0 0
1 0 1</lang>


=={{header|Java}}==
=={{header|Java}}==