New stable release(v1.0.6)
dc / build (push) Successful in 17s Details

This commit is contained in:
Marco Cetica 2024-04-19 16:34:57 +02:00
parent 9d5aeebef3
commit d270cb7d9c
Signed by: marco
GPG Key ID: 45060A949E90D0FD
8 changed files with 26 additions and 4 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/dc-1.0.6-2.x86_64.rpm Normal file

Binary file not shown.

BIN
bin/dc-1.0.6.x86_64.deb Normal file

Binary file not shown.

4
man.md
View File

@ -3,7 +3,7 @@ title: dc
section: 1
header: General Commands Manual
footer: Marco Cetica
date: April 19, 2024
date: April 22, 2024
---
@ -238,7 +238,7 @@ $$
z = a + ib
$$
write the _real_ part($a$) into the _second-to-top_ of the stack, the _imaginary_ part($b$) into the `x` _head_ of the stack and then issue the `b` command. For example, to enter $(9 + 4i)$, write:
write the _real_ part($a$) into the _second-to-top_ of the stack, the _imaginary_ part($b$) into the _head_ of the stack and then issue the `b` command. For example, to enter $(9 + 4i)$, write:
```
9 4 b p

View File

@ -388,8 +388,30 @@ std::optional<std::string> Mathematics::fn_exp(dc::Stack<std::string> &stack, co
auto exp = std::stod(stack.pop(true));
auto base = std::stod(stack.pop(true));
// Push back the result as a string
stack.push(trim_digits(pow(base, exp), parameters.precision));
std::complex<double> power;
// If base is positive or exponent is an integer
// calculate pow with real numbers. Otherwise
// with complex numbers
if(base > 0 || std::fmod(exp, 1.0) == 0) {
power = std::pow(base, exp);
} else {
power = std::pow(std::complex<double>(base), exp);
}
// Check if result is a complex number
if(std::imag(power) != 0) {
// trim their digits
auto real_trimmed = trim_digits(power.real(), parameters.precision);
auto imag_trimmed = trim_digits(power.imag(), parameters.precision);
auto complex_str = ('(' + real_trimmed + ',' + imag_trimmed + ')');
// Push the result back onto the stack
stack.push(complex_str);
} else {
// Push the result back onto the stack
stack.push(trim_digits(std::real(power), parameters.precision));
}
} else if(is_x_cmplx || is_y_cmplx) {
stack.copy_xyz();
// Convert complex dc objects(ie strings) to std::complex