Zeckendorf arithmetic: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
No edit summary
Line 16: Line 16:
:To be completed.
:To be completed.


=={{header|C++}}==
Division.
Division.


:To be completed.
:To be completed.

=={{header|C++}}==

Revision as of 12:44, 29 October 2012

Zeckendorf arithmetic is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Zeckendorf number representation is described Here. It looks like binary. The purpose of this task is to explore why Babbage et al. may have preferred binary to zeckendorf when designing computers. Here I extended that task by adding an increment and comparison operator. This task will implement addition; subtraction; multiplication; and division using zeckendorf.

Addition.

Like binary 1 + 1 = 10, note carry 1 left. There the similarity ends. 10 + 10 = 101, note carry 1 left and 1 right. 100 + 100 = 1001, note carry 1 left and 2 right, this is the general case.

Occurances of 11 must be changed to 100. Ocurances of 111 may be changed from the right by replacing 11 with 100, or from the left converting 111 to 100 + 100;

Subtraction.

To be completed.

Multiplication.

To be completed.

Division.

To be completed.

C++