Skip to content

[DQ.h] Fix operator-(Scalar, DQ), which returned dq - s instead of s … - #79

Merged
mmmarinho merged 1 commit into
dqrobotics:masterfrom
juanjqo:hotfix_minus
Nov 16, 2026
Merged

mmmarinho merged 1 commit into
dqrobotics:masterfrom
juanjqo:hotfix_minus

Conversation

@juanjqo

@juanjqo juanjqo commented Nov 16, 2026

Copy link
Copy Markdown
Member

@dqrobotics/developers

Hi, @mmmarinho

While implementing my custom dec_mult, I found a bug in operator-(const Scalar& s, const DQ& dq). It returns dq - s instead of s - dq:

2 - i_ = -2 + 1i

(In MATLAB, DQ(2) - i_ or 2-DQ.ireturns 2 - 1i). This PR fixes the operator and its documentation.

Kind regards,

Juancho

Minimal example

#include <dqrobotics/DQ.h>
#include <iostream>
using namespace DQ_robotics;

int main()
{
    std::cout << "2 - i_     = " << 2 - i_ << std::endl;
    std::cout << "DQ(2) - i_ = " << DQ(2) - i_ << std::endl;
}

Output (master)

2 - i_     =  - 2 + 1i
DQ(2) - i_ = 2 - 1i

Output (this PR)

2 - i_     = 2 - 1i
DQ(2) - i_ = 2 - 1i

@mmmarinho
mmmarinho merged commit 48180c2 into dqrobotics:master Nov 16, 2026
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants