matmoul b6ca7d6b75 fix(hp48): render edited stack lines while editing
Use the input value for the first line and shift stack lookups down for
subsequent lines during edit mode. Also route Enter through execute() so
editing state is handled consistently before re-rendering.
2026-04-24 21:08:50 +02:00

RPN Virtual Calculator

A browser-friendly RPN calculator built around a small, generic JavaScript API.

Goal

This project defines a reusable RPN calculator engine with:

  • a simple stack-based public API
  • configurable numeric and UI behavior
  • centralized command metadata
  • a browser demo that uses the same public API as any consumer code

Package contents

  • rpn-calculator.js: calculator engine
  • rpn-example.html: example browser interface

Main features

  • Single JavaScript class
  • Configurable stack size (maxSize, default: 2048)
  • Configurable numeric base (base, default: 10)
  • Configurable angle mode (angleMode, default: deg)
  • Optional command filtering through enabledCommands
  • Generic public API centered on:
    • push
    • pop
  • clear
    • swap(index1, index2)
    • remove(index)
    • edit(index)
    • isValidIndex(index)
    • input(command)
    • command(name, ...args)
  • inputValue is kept as a string to preserve future input formats
  • isEditing is exposed as a boolean state
  • All supported commands are described in one centralized dictionary
  • Supported categories are limited to:
    • Stack
    • Arithmetic
    • Trigonometry

Basic usage

In a browser

S
Description
No description provided
Readme 590 KiB
Languages
JavaScript 82.6%
Shell 17.4%