Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Division Bug in Programmer Dec Mode #2300

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/CalcManager/Ratpack/support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ void intrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
DUPRAT(pret, *px);
remrat(&pret, rat_one);

// Flatten pret in case it's not aligned with px after remrat operation
if (!equnum((*px)->pq, pret->pq))
{
flatrat(pret, radix, precision);
}

subrat(px, pret, precision);
destroyrat(pret);

Expand Down
25 changes: 25 additions & 0 deletions src/CalculatorUnitTests/CalculatorManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,31 @@ namespace CalculatorManagerTest

Command commands10[] = { Command::ModeProgrammer, Command::Command1, Command::CommandRORC, Command::CommandRORC, Command::CommandNULL };
TestDriver::Test(L"-9,223,372,036,854,775,808", L"RoR(RoR(1))", commands10, true, false);

Command commands11[] = { Command::ModeProgrammer, Command::CommandDec, Command::Command4, Command::Command2, Command::Command9, Command::Command4,
Command::Command9, Command::Command6, Command::Command7, Command::Command2, Command::Command9, Command::Command6,
Command::CommandDIV, Command::Command2, Command::Command5, Command::Command5, Command::CommandEQU, Command::CommandNULL };
TestDriver::Test(L"16,843,009", L"4294967296 \x00F7 255=", commands11, true, false);

Command commands12[] = {
Command::ModeProgrammer, Command::CommandDec, Command::Command4, Command::Command2, Command::Command9, Command::Command4,
Command::Command9, Command::Command6, Command::Command7, Command::Command3, Command::Command0, Command::Command3,
Command::CommandDIV, Command::Command2, Command::Command5, Command::Command5, Command::CommandEQU, Command::CommandNULL
};
TestDriver::Test(L"16,843,009", L"4294967303 \x00F7 255=", commands12, true, false);

Command commands13[] = {
Command::ModeProgrammer, Command::CommandDec, Command::Command1, Command::Command0, Command::Command0, Command::Command0,
Command::Command0, Command::Command0, Command::Command0, Command::Command0, Command::Command0, Command::Command0, Command::CommandDIV,
Command::Command6, Command::Command4, Command::Command4, Command::Command8, Command::Command7, Command::CommandEQU, Command::CommandNULL
};
TestDriver::Test(L"15,507", L"1000000000 \x00F7 64487=", commands13, true, false);

Command commands14[] = { Command::ModeProgrammer, Command::CommandDec, Command::Command1, Command::Command0, Command::Command0,
Command::Command0, Command::Command0, Command::Command0, Command::Command0, Command::Command0,
Command::Command0, Command::Command0, Command::CommandDIV, Command::Command6, Command::Command4,
Command::Command4, Command::Command8, Command::Command8, Command::CommandEQU, Command::CommandNULL };
TestDriver::Test(L"15,506", L"1000000000 \x00F7 64488=", commands14, true, false);
}

void CalculatorManagerTest::CalculatorManagerTestMemory()
Expand Down