Metadata-Version: 2.3
Name: dailycalc
Version: 2024.0.1.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

# DailyCalc - A Simple Calculator

**python\>=3.11**

**dependency** : **[colorama](https://pypi.org/project/colorama/)**
(**not mandatory**, if you don't need highlight, you can uninstall it later)

## Description

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

Output is rounded with maximum 10 decimal place for Infinitesimal decimals.

```bash
sqrt(2)     => 1.4142135624   # keep 10 decimal places
0.1 + 0.2   => 0.3
ln(exp(10)) => 10.0000000000  # inevitable loss of precision
```

## Usage

install by pip

```bash
pip install dailycalc
```

import into your code

```python
from dailycalc import calculate, check_calc

if check_calc("sum(123, 3)"):
    print(calculate("sum(123, 3)"))

# or

try:
    print(calculate("sum(123, 3)"))
except ValueError as e:
    print(e)
```

once-off calculate

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

iteractive mode

```bash
python -m dailycalc -i
# or
idailycalc
```

## Operators & Functions

supporting:

`+ - \* / ^`

`sum max min abs round hex oct sqrt log ln exp`

## 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:

![image](/ext/exp.png)

## Support HEX, OCT, Scientific input

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

## Error message with highlight

![image](./ext/error_message.png)

### 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
sqrt(1.44)         => 1.2
ln(exp(100))       => 10.0000000000
log(100)           => 2
```

## Future Plans

add more function & operator, bugfix.
