New stable release(v1.0.6)
This commit is contained in:
parent
9d5aeebef3
commit
6b0aca61f0
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/dc-1.0.6-1-x86_64.pkg.tar.zst
Normal file
BIN
bin/dc-1.0.6-1-x86_64.pkg.tar.zst
Normal file
Binary file not shown.
BIN
bin/dc-1.0.6-2.x86_64.rpm
Normal file
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
BIN
bin/dc-1.0.6.x86_64.deb
Normal file
Binary file not shown.
4
man.md
4
man.md
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user