-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Contraculator is a philosophical calculator that is freed as much as possible from most of the pre-assumptions that are imposed by the variables dependent on the present evolutionary path that human-beings are developed. this project is far from completion. the goal is to get maximum detachment from everything imposed by human-being and its environment, to see how far it can go, and how else it would have gone, in order to explore possibilities and be more conscious of actuality of the mathematics as a whole.
Why it is called Contraculator:
the term "Contraculator" is a play with the words "Calculator" and "Contract" which refers to the fact that mathematics is fundamentally structured by Contracts made by men, within the current evolutionary path that math has taken; the question that comes to the mind is: which Contracts are more optional, and which are as fundamental as being a necessity.
Key Concepts:
The code primarily operates in decimal for arithmetic and uses the custom numeral system for input and output representation. The custom numeral system is a visual and input-output interface, but all arithmetic happens in base-10.
Custom Numeral System:
The user can define a custom numeral system by entering a string of symbols (e.g., "0123456789", "ABCDEF", etc.). The length of this string determines the base. For example, "0123456789" is base-10, "01" is base-2 (binary), "ABC" would be base-3, etc.
Base and Custom Numerals:
The variable base is dynamically updated based on the length of the custom numeral string. customNumerals stores the symbols representing each digit in the custom base system.
Process Flow
Input Setup:
The user inputs a custom numeral string into the "numerals" input field. When the user clicks "Apply," the customNumerals variable is updated, and base is set to the length of this string.
Placeholder Updates:
The placeholder text in the input field (inDecimal) is updated to reflect the available digits for the current base. For example, if the base is 10, the placeholder shows "0,1,2,3,...,9". Performing Calculations:
When the user enters a mathematical expression in the "calculation" input field and presses Enter, the application processes this input. The function evaluateCalculation(calculation) replaces each custom numeral with its corresponding decimal equivalent. The modified calculation string, now in decimal, is passed to the evaluate(calculation) function, which performs the arithmetic in decimal.
Result Conversion:
After the arithmetic operation is completed in decimal, the result is converted back into the custom base using convertToCustomBase(result). The final result, now in the custom numeral system, is displayed to the user.
Mechanism of the Code
Base Conversion:
The calculation itself is performed in decimal. The custom numerals are only used as a representation.
The steps are as follows: Convert Input: Convert custom numeral inputs into their decimal equivalents. Perform Calculation: Execute the arithmetic operations in the decimal system. Convert Result: Convert the result back into the custom numeral system for display.
Flow of Data:
Input: Custom numeral system → Conversion to decimal Processing: Calculation in decimal Output: Conversion back to the custom numeral system → Display Example: Assume the user defines a custom numeral system "ABC", which is base-3.
The user inputs a calculation like "AB + C". This is converted into decimal: "12 + 2" (where A=1, B=2, C=2). The decimal calculation 12 + 2 is performed, yielding 14. The result 14 is then converted back into base-3: "BB". The final result shown to the user is "BB".