Skip to content

Commit

Permalink
Fixed incorrect result in multiplication (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZCG-coder committed Apr 8, 2024
1 parent d0dc3fd commit 30d1cde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ foreach (COMPONENT IN LISTS COMPONENTS)

if (DEFINED STP_BUILD_COMPONENT_EXECUTABLE)
add_executable(${COMPONENT} ${COMPONENT}/${COMPONENT}.cpp ${COMPONENT}/${COMPONENT}Report.cpp)
target_include_directories(${COMPONENT} PRIVATE ${STP_BASE_DIRECTORY}/include/)
target_link_libraries(${COMPONENT} calc)
endif ()

Expand Down
5 changes: 3 additions & 2 deletions src/multiply/multiply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ namespace steppable::__internals::arithmetic
for (size_t indexB = 0; indexB < bStr.length(); indexB++)
{
const int bDigit = static_cast<int>(bStr[indexB]) - '0';
if (bDigit == 0)
continue;
// Skip if the digit is 0. This seems to cause issues (#5), so it's commented out for now.
// if (bDigit == 0)
// continue;
std::vector<int> currentProdDigits(aStr.length() + bStr.length() + 1, 0),
currentCarries(aStr.length() + bStr.length() + 1, 0);
for (long long indexA = static_cast<long long>(aStr.length()) - 1; indexA != -1; indexA--)
Expand Down

0 comments on commit 30d1cde

Please sign in to comment.