Metadata-Version: 2.3
Name: dailycalc
Version: 2024.0.1
Summary: A simple calcaultor for daily usage
Project-URL: Homepage, https://github.com/quxiaowei/simple-calculator
Project-URL: Issues, https://github.com/quxiaowei/simple-calculator/issues
Author-email: Qu Xiaowei <quxw.work@gmail.com>
License: Copyright (c) 2018 The Python Packaging Authority
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.11
Requires-Dist: colorama>=0.4.6
Description-Content-Type: text/markdown

# A Simple Calculator

Based on decimal.Decimal.

> Decimal “is based on a floating-point model which was designed with people in mind, and necessarily has a paramount guiding principle – computers must provide an arithmetic that works in the same way as the arithmetic that people learn at school.” – excerpt from the decimal arithmetic specification

### How to use

install

```
pip install dailycalc
```

import into your code

```python
from dailycalc import calculate

print(calculate("sum(123+3)"))
```

once-off calculate

```bash
python -m dailycalc "sum(0.1, 0.2)"
```

iteractive mode

```bash
python -m dailycalc -i
```

### Operators & Functions

currently supporting:

"+ - \* / ^"

"sum max min abs round hex oct"

### Interactive mode

Every result is stored in register from \[a-z\] cyclically, that is when reaching the last one "z", the register would go back to "a" and cover the old value.

"@a" gives the value in "a". "@@" gives the previous result.'

for example:

```
>>> 1
>>> @a: 1
>>> @a + 2
>>> @b: 3
>>> ...
>>> @z: 351
>>> @z + 1
>>> @a: 352
>>> @@- 1
>>> @b: 351
```

### Support HEX, OCT, Scientific input

1. HEX: "0x12E", "0X12E" only support integar
2. OCT: "0o123", "0O123" only support integar
3. Scientific: "-123.12E-123" or "-123.12e+123"

### Support terminal highlight in -i

### Error message with highlight

```

>>> abs(sum(1,2,3),11)
>>> Input: abs(sum(1,2,3),11)
           ---------------^^-----
    Error: func abs: expecting 1 parameters got 2
>>>
```

```
>>> sum(1,
>>> Input: sum(1,
           ------^---
    Error: expecting Number
>>>
```

### reference for interactive mode

```

--- Modes ---
STAY mode (prompt:"===") (Default)
save result by call "save" command
WALKING mode (prompt:">>>")
automatically save results and move to next register
--- Commands ---
"exit" exit program.
"show" show all results in register.
"reset" clear all results in register.
"stay" switch to STAY mode.
"go" save result & switch to WALKING mode.
"save [tag]" save result (in STAY Mode).
--- Functions ---
sum(1, 2, 2+1) => 6
max(1, sum(2, 1)) => 3
min(1, 2) => 1
abs(1-12) => 11
round(12.16, 1) => 12.2
hex(10) => 0xa
oct(10) => 0o12

```

### Require colorama [https://pypi.org/project/colorama/]

## Future Plans

add more function & operator, bugfix.
