1.6 KiB
1.6 KiB
Project rules — RPN Virtual Calculator
- Build a browser-friendly RPN calculator as a JavaScript class, preferably in a single file.
- Constructor options:
maxSize(default 2048),base(default 10),angleMode(degdefault; alsoradandgrad),enabledCommands. - Available constants:
pi,e. - Public API is generic only:
push,pop,clear,swap(index1, index2),remove(index),edit(index),isValidIndex(index),input(command), andcommand(name, ...args). - Expose
inputValueas a string andisEditingas a boolean. - Supported operations are centralized in one dictionary with
argCount, category, and aliases. - Categories are limited to
Stack,Arithmetic, andTrigonometry. - Current commands:
add,sub,mul,div,mod,pow,sqr,neg,sqrt,recip,sin,cos,tan,asin,acos,atan,log,ln,dup,drop,swap,clear,enter. - Aliases:
+,-,*,/,%,^,y^x,1/x. modis the percentage operator:a b % => (a * b) / 100.sqrt,asin,acos,log, andlnmust throw clear, explicit domain errors.logusesMath.log10;lnusesMath.log.- Trig functions use degrees in the demo;
sin,cos,tanconvert to radians, inverse trig returns degrees. inputValuestays a string to keep hexadecimal input possible later.- Example HTML must group buttons by
Stack,Arithmetic, andTrigonometry, and callcommand(...). - Keep code names, categories, and API identifiers in English.
- Keep this file updated after each project change using the provided editing tools.