{"id":13408802,"url":"https://github.com/leonmavr/HIP35","last_synced_at":"2025-03-14T13:32:05.312Z","repository":{"id":203185295,"uuid":"686599819","full_name":"leonmavr/HIP35","owner":"leonmavr","description":"HP-35 RPN calculator emulator in C++17 with a terminal user interface ","archived":false,"fork":false,"pushed_at":"2024-06-17T12:31:48.000Z","size":67076,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-07-31T20:32:00.372Z","etag":null,"topics":["calculator","cpp","emulator","hp-35","ncurses","rpn"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leonmavr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-03T10:43:50.000Z","updated_at":"2024-06-17T12:31:51.000Z","dependencies_parsed_at":"2023-12-01T13:42:19.744Z","dependency_job_id":"1a813892-09ce-40ab-b15d-1259fe89ff07","html_url":"https://github.com/leonmavr/HIP35","commit_stats":null,"previous_names":["leonmavr/hip35"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonmavr%2FHIP35","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonmavr%2FHIP35/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonmavr%2FHIP35/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonmavr%2FHIP35/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leonmavr","download_url":"https://codeload.github.com/leonmavr/HIP35/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243584464,"owners_count":20314765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["calculator","cpp","emulator","hp-35","ncurses","rpn"],"created_at":"2024-07-30T20:00:55.344Z","updated_at":"2025-03-14T13:32:04.633Z","avatar_url":"https://github.com/leonmavr.png","language":"C++","readme":"```\n .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. \n| .--------------. | .--------------. | .--------------. | .--------------. | .--------------. | .--------------. |\n| |  ____  ____  | | |     _____    | | |   ______     | | |              | | |    ______    | | |   _______    | |\n| | |_   ||   _| | | |    |_   _|   | | |  |_   __ \\   | | |              | | |   / ____ `.  | | |  |  _____|   | |\n| |   | |__| |   | | |      | |     | | |    | |__) |  | | |    ______    | | |   `'  __) |  | | |  | |____     | |\n| |   |  __  |   | | |      | |     | | |    |  ___/   | | |   |______|   | | |   _  |__ '.  | | |  '_.____''.  | |\n| |  _| |  | |_  | | |     _| |_    | | |   _| |_      | | |              | | |  | \\____) |  | | |  | \\____) |  | |\n| | |____||____| | | |    |_____|   | | |  |_____|     | | |              | | |   \\______.'  | | |   \\______.'  | |\n| |              | | |              | | |              | | |              | | |              | | |              | |\n| '--------------' | '--------------' | '--------------' | '--------------' | '--------------' | '--------------' |\n '----------------' '----------------' '----------------' '----------------' '----------------' '----------------'\n```\n\u003csub\u003e(ASCII art by [patorjk.com](https://patorjk.com/software/taag))\u003c/sub\u003e\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![C/C++ CI build \u0026 test](https://github.com/leonmavr/HIP35/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/leonmavr/HIP35/actions/workflows/c-cpp.yml)\n\n## 1. Introduction\n\n### What's this project?\nHIP-35 is a calculator for hipsters. It emulates the RPN (reverse\nPolish notation) mode of HP-35 from 1972. It runs a terminal UI\nbuilt with ncurses that displays the current result on a display.\n\n### ⚫ Why RPN?\n\nBecause it genally involves less keystrokes and it's faster than\nalgebraic notation calculations.  \n\nHow? RPN makes it very easy to compute long expressions containing\nlots of brackets [[1]](#ref-1). When using it, you don't need\nto think how terms are grouped anymore.\n\n### ⚫ The memory\nHP-35 had a stack-based memory of 4 registers `X`, `Y`, `Z`, `T`\nwith `X` being the bottom (entry). That stack shifts (lifts or\ndrops) automatically as calculations are performed. There are\nalso 10 general registers labelled `A` to `J` that store values,\nacting as buffers.\n\n| HP-35 | HIP-35 |\n|---------|---------|\n| \u003cimg src=\"https://raw.githubusercontent.com/leonmavr/HIP35/master/assets/wiki_image.jpg\" alt=\"HP 35 front face\" height=\"325\"/\u003e | \u003cimg src=\"https://raw.githubusercontent.com/leonmavr/HIP35/master/assets/demo_screenshot.png\" alt=\"hip 35 screenshot\" height=\"325\"/\u003e |\n\n## 2. Usage\n\n### ⚫ Dependencies\n\nCMake is required to build the project and ncurses for the frontend.\nAlso you need to make sure your compuler supports **C++17** or higher.\nInstall both packages by:\n\n| Arch-based                     | Debian-based                                       |\n|--------------------------------|----------------------------------------------------|\n| `sudo pacman -S cmake ncurses` | `sudo apt install cmake libncurses5 libncursesw5`  |\n\n### ⚫ Compilation\nThe build system is based on CMake. To build the project run:\n```\ncmake . -Bbuild\ncd build\nmake -j\n```\nor alternatively just execute the `build.sh` script:\n```\n./build.sh\n```\nThe demo executable that runs the UI will be generated at\n```\n./build/demo/demo\n```\nThat's it, have fun doing RPN calculations!\n\nA unit test executable is also generated at\n`./build/test/testhip35`.\n\n### ⚫ The keys\n\nMost keys are self-explanatory. However, some are less straightforward.\n\n| key   | description             | syntax    | before            | argument | after             |\n|-------|-------------------------|-----------|-------------------|----------|-------------------|\n| CHS   | change sign of X        | `CHS`     | 4                 |          | -4                |\n| ENTER | duplicate X to Y        | `ENTER`   | `T,Z,Y,X=1,2,3,4` |          | `T,Z,Y,X=2,3,4,4` |\n| LASTX | last X before operation | `LASTX`   | `4 E 20 +` (X=24) |          | `X=20`            |\n| RDN   | rotate stack down       | `RDN`     | `T,Z,Y,X=1,2,3,4` |          | `T,Z,Y,X=4,3,2,1` |\n| STO   | store to A-J e.g. A = X | `STO a-j` | `X=3.14, A=0`     | a        | `X=3.14, A=3.14`  |\n| RCL   | recall to X e.g. X = A  | `RCL a-j` | `X=0, F=2.71`     | f        | `X=2.71, F=2.71`  |\n| EEX   | exponentiation of X     | `EEX N`   | 7                 | 3        | 7000              |\n| CLX   | clear register X        | `CLX`     | 12345             |          | 0                 |\n| CLR   | clear entire stack      | `CLR`     | `T,Z,Y,X=1,2,3,4` |          | `T,Z,Y,X=0,0,0,0` |\n| q     | quit application        | `q`       |                   |          |                   |\n\n\n\nEnter (`\u003cspace\u003e`) needs to be pressed to separate two successive\nnumbers. When running the UI, press `q` to quit. `\u003cCtr-C\u003e` is \nnot captured so `q` is the only way to quit. You can read more \nat the [HP35 manual](https://literature.hpcalc.org/community/hp35-om-en-reddot.pdf)\n[[4]](#ref-4).\n\n### ⚫ Project directory structure and source code\n\nImplementations are found at `lib/src` and header files at `lib/inc`. The demo application is at `demo/main.cpp` and unit tests are found at `test/test.cpp`. \n\nYou can create an instance of the Hip35 class and run it either via \nthe UI or without it (given a string) as follows:\n```\n#include \"hip35.h\"\n//...\nauto hp = std::make_unique\u003cUi::Hip35\u003e(key::keypad);\n// using the UI\nhp-\u003eRunUI();\n// or without it\nauto result = hp-\u003eEvalString(\"430 ENTER 80 - 1.2 *\");\n```\n\n## 3. Demo\n\nSecond order equation by using storage/recall:\n\nhttps://github.com/leonmavr/HIP35/assets/13514096/911e7cce-2db0-4705-92fd-c3dfa6142de6\n\nThe fraction `sqrt(2 + (sin(25) + pi/2)^2)/3`:\n\nhttps://github.com/leonmavr/HIP35/assets/13514096/ee05b992-8901-4ffe-9649-71dfb9cda71c\n\n\n## 4. Basic theory\n### ⚫ What is RPN?\n\nRPN allows a stack-based evaluation of numerical expressions,\neliminating the need of brackets. There are two main ideas behind\nRPN:\n1. operands (numbers) are pushed in a stack\n2. it follows the postfix notation, i.e. each operator follows one\nor two operands preceeding it\n\nPhysical calculators need a way to separate successive numbers,\naccomplished with the enter (E) key.\n\nFor example:\n```\n+------------+---------------+-------------------+-----------------------------------------------+\n| Algebrainc | RPN           | Physical          | Stack contents                                |\n| expression | equivalent    | calculator        |                                               |\n+------------+---------------+-------------------+-----------------------------------------------+\n| 1 + 2      | 1 2 +         | 1 E 2 +           | [1], [1,1], [1,2], [3]                        |\n+------------+---------------+-------------------+-----------------------------------------------+\n| 1 + 2 - 3  | 1 2 3 + - or: | 1 E 2 E 3 + -     | ...[1,2], [1,2,2], [1,2,3], [1,-1], [0]       |\n|            | 1 2 + 3 -     | 1 E 2 + 3 -       | ...[1,2], [3], [3,-3], [0]                    |\n+------------+---------------+-------------------+-----------------------------------------------+\n| (1+2)(3+4) | 1 2 + 3 4 + * | 1 E 2 + 3 E 4 + * | ...[1,2], [3], [3,3], [3,3,4], [3,7], [21]    |\n+------------+---------------+-------------------+-----------------------------------------------+\n| 13*sin(37) | 13 37 SIN *   | 13 E 37 SIN *     | [13], [13,13], [13,37] [13,s(37)], [13*s(37)] |\n+------------+---------------+-------------------+-----------------------------------------------+\n```\nYou can practise more with RPN by using the script `docs/rpn.py`\nwhich evaluates RPN expressions from a string. Numbers are\nseparated by space in this script so you don't need to press enter.\n\n\n### ⚫ HIP-35 additional features\nHIP-35 includes some minor additions compared to HP-35:\n* The display now has two rows, displaying the X and Y registers\ninstead of just X.\n* There is space on the right to display the 10 general registers.\nBack in the day users had to write down which register stores\nwhat.\n* User can also enter negative numbers using the `~` as the unary\nminus. HP35 only supposed the `CHS` (change sign) operation for\nthat.\n* There is no `ARC` key. `ARC` key had to pressed to enable the\n`SIN, COS, TAN` keys to compute `ASIN, ACOS, ATAN`. The latter\nkeys are directly implemented in HIP-35.\n* The number format on the display is automatically adjusted based\non the range the number is in.\n* The `LASTX` key from HP-35s is ported as it makes certain \ncalculations much faster.\n\nYou can read more at the [wiki](https://en.wikipedia.org/wiki/HP-35)\npage, at [HP museum](https://www.hpmuseum.org/hp35.htm) or at the\n[HP-35s manual](http://h10032.www1.hp.com/ctg/Manual/c01579350),\nwhich is its successor.\n\n### ⚫ Cool trivia\n\n* HP35 was the first ever scientific pocket calculator. It was\n  released in 1972. Before that, the only practical portable\n  devices for performing trigonometric and exponential functions\n  were slide rules [[2]](#ref-2)\n* The co-founder of HP himself, Bill Hewlett, challenged his\ncoworkers to create it as a \"shirt-pocket sized HP-9100“ (HP-9100\nwas a scientific computer from the 60s).\n* HP-35 calculators, were used by NASA's Skylab crew from 1973 to\n1974 [[3]](#ref-3). It's rumored to be the first\ncalculator to ever fly into space. It helped the crew write\nprograms that perform calculations related to the spacecraft's\norbit around the moon (Lunar Orbital Rendezvous or LOR).\n* It was able to perform calculations both in algebraic a RPN mode.\n\n## 5. Future ideas\n\n- [ ] Paste text into display\n- [ ] In headless mode (parsing a string), throw an error instead of\n      continuing when a token is unknown.\n- [ ] (ambitious) write a compiler for the HP35/HP35s programming\n\t  language and be able to write routines by pressing a key.\n\n## References\n\n[1] \u003ca name=\"ref-1\"\u003e\u003c/a\u003e[Dr Marshall Leach Jr's page](https://leachlegacy.ece.gatech.edu/revpol/)  \n[2] \u003ca name=\"ref-2\"\u003e[Interview with David Cochran](https://killerinnovations.com/interview-with-david-cochran-on-creating-the-hp35-calculator/)  \n[3] \u003ca name=\"ref-3\"\u003e\u003c/a\u003e[History of Space Shuttle Rendezvous, Oct 2011](https://core.ac.uk/download/pdf/10564548.pdf)  \n[4] \u003ca name=\"ref-4\"\u003e\u003c/a\u003e[HP35 manual](https://literature.hpcalc.org/community/hp35-om-en-reddot.pdf)  \n\n","funding_links":[],"categories":["\u003ca name=\"calc\"\u003e\u003c/a\u003eCalculators"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonmavr%2FHIP35","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleonmavr%2FHIP35","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonmavr%2FHIP35/lists"}