Skip to content

Commit 224ccdf

Browse files
author
Ishuah Kariuki
committed
Update intrat function
added a programmer mode test case
1 parent 41fc032 commit 224ccdf

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/CalcManager/Ratpack/support.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ void intrat(_Inout_ PRAT* px, uint32_t radix, int32_t precision)
303303
DUPRAT(pret, *px);
304304
remrat(&pret, rat_one);
305305

306+
// Flatten pret in case it's not aligned with px after remrat operation
307+
if (!equnum((*px)->pq, pret->pq))
308+
{
309+
flatrat(pret, radix, precision);
310+
}
311+
306312
subrat(px, pret, precision);
307313
destroyrat(pret);
308314

src/CalculatorUnitTests/CalculatorManagerTest.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,11 @@ namespace CalculatorManagerTest
752752

753753
Command commands10[] = { Command::ModeProgrammer, Command::Command1, Command::CommandRORC, Command::CommandRORC, Command::CommandNULL };
754754
TestDriver::Test(L"-9,223,372,036,854,775,808", L"RoR(RoR(1))", commands10, true, false);
755+
756+
Command commands11[] = { Command::ModeProgrammer, Command::CommandDec, Command::Command4, Command::Command2, Command::Command9, Command::Command4,
757+
Command::Command9, Command::Command6, Command::Command7, Command::Command2, Command::Command9, Command::Command6,
758+
Command::CommandDIV, Command::Command2, Command::Command5, Command::Command5, Command::CommandEQU, Command::CommandNULL };
759+
TestDriver::Test(L"16,843,009", L"4294967296 \x00F7 255=", commands11, true, false);
755760
}
756761

757762
void CalculatorManagerTest::CalculatorManagerTestMemory()

0 commit comments

Comments
 (0)