Skip to content

Commit b93951c

Browse files
committed
Fixes
1 parent dae5fa6 commit b93951c

23 files changed

+60
-65
lines changed

include/constants.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
namespace steppable::constants
3232
{
3333
/// @brief 100 digits of pi.
34-
extern const std::string_view& PI;
34+
extern const std::string_view PI;
3535

3636
/// @brief Pi multiplied by 2.
3737
// Generated using Python:
@@ -43,7 +43,7 @@ namespace steppable::constants
4343
// 5 | 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
4444
// 6 | ) * Decimal(2)
4545
// -------------------------------------------------------
46-
extern const std::string_view& TWO_PI;
46+
extern const std::string_view TWO_PI;
4747

4848
/// @brief Pi divided by 2.
4949
// Generated using Python:
@@ -55,7 +55,7 @@ namespace steppable::constants
5555
// 5 | 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
5656
// 6 | ) / Decimal(2)
5757
// -------------------------------------------------------
58-
extern const std::string_view& PI_OVER_2;
58+
extern const std::string_view PI_OVER_2;
5959

6060
/// @brief Pi divided by 180 (to convert degrees to radians), correct to 100 decimal places.
6161
// Generated using Python:
@@ -67,7 +67,7 @@ namespace steppable::constants
6767
// 5 | 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
6868
// 6 | ) / Decimal(180)
6969
// -------------------------------------------------------
70-
extern const std::string_view& PI_OVER_180;
70+
extern const std::string_view PI_OVER_180;
7171

7272
/// @brief Pi divided by 200 (to convert grads to radians), correct to 100 decimal places.
7373
// Generated using Python:
@@ -79,7 +79,7 @@ namespace steppable::constants
7979
// 5 | 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
8080
// 6 | ) / Decimal(200)
8181
// -------------------------------------------------------
82-
extern const std::string_view& PI_OVER_200;
82+
extern const std::string_view PI_OVER_200;
8383

84-
extern const std::string_view& E;
84+
extern const std::string_view E;
8585
} // namespace steppable::constants

include/testing.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ namespace steppable::testing
112112
* @brief Constructs a new TestCase object with the given name.
113113
* @param[in] testCaseName The name of the test case.
114114
*/
115-
explicit TestCase(const std::string& testCaseName);
115+
explicit TestCase(std::string testCaseName);
116116

117117
/**
118118
* @brief Asserts that two strings are equal.

src/base/baseConvert/baseConvert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ namespace steppable::prettyPrint::printers
5555
auto height = prettyPrint::getStringHeight(base) + 1; // +1 for the superscript
5656

5757
prettyPrint::ConsoleOutput output(height, width);
58-
prettyPrint::Position pos{ static_cast<long long>(width - subscriptWidth - 1), 1 };
58+
prettyPrint::Position pos{ .x = static_cast<long long>(width - subscriptWidth - 1), .y = 1 };
5959
output.write(subscript, pos, false);
60-
output.write(base, { 0, 0 }, false);
60+
output.write(base, { .x = 0, .y = 0 }, false);
6161
return output.asString();
6262
}
6363
} // namespace steppable::prettyPrint::printers

src/base/baseConvert/baseConvertReport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ std::string reportBaseConvert(const std::string& _number,
6767
ss << _number << steppable::__internals::symbols::makeSubscript("10") << " = ";
6868
// Output the result in reverse order
6969
auto result = _result;
70-
std::reverse(result.begin(), result.end());
70+
std::ranges::reverse(result);
7171
for (const auto& item : result)
7272
ss << item;
7373
if (steps == 1)

src/calc/add/add.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ namespace steppable::__internals::calc
120120
std::ranges::reverse(aStr);
121121
std::ranges::reverse(bStr);
122122

123-
std::vector sumDigits(aStr.length() + 1, 0);
124-
std::vector carries(aStr.length() + 1, false);
123+
std::vector<int> sumDigits(aStr.length() + 1, 0);
124+
std::vector<int> carries(aStr.length() + 1, 0);
125125

126126
for (size_t index = 0; index < aStr.length(); index++)
127127
{
@@ -138,7 +138,7 @@ namespace steppable::__internals::calc
138138
{
139139
sumDigits[index] -= 10;
140140
sumDigits[index + 1] += 1;
141-
carries[index + 1] = true;
141+
carries[index + 1] = 1;
142142
}
143143
}
144144

@@ -150,10 +150,10 @@ namespace steppable::__internals::calc
150150
const auto& itCarries = carries.begin();
151151

152152
sumDigits.insert(itSumDigits + static_cast<long>(decimalPos), -1); // -1 indicating a decimal point
153-
carries.insert(itCarries + static_cast<long>(decimalPos), false); // Reserve the space
153+
carries.insert(itCarries + static_cast<long>(decimalPos), 0); // Reserve the space
154154
}
155155

156-
std::reverse(carries.begin(), carries.end());
156+
std::ranges::reverse(carries);
157157
std::ranges::reverse(sumDigits);
158158
if (sumDigits.front() == 0 and properlyFormat)
159159
sumDigits.erase(sumDigits.begin());

src/calc/add/addReport.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ std::string reportAdd(const std::string& aInteger,
4747
const std::string& bInteger,
4848
const std::string& bDecimal,
4949
const std::vector<int>& sumDigits,
50-
const std::vector<bool>& carries,
50+
const std::vector<int>& carries,
5151
const bool resultIsNegative,
5252
const int steps,
5353
const bool properlyFormat)
@@ -60,12 +60,8 @@ std::string reportAdd(const std::string& aInteger,
6060
std::string bOut = bInteger;
6161
if (aIsDecimal)
6262
aOut += '.' + aDecimal;
63-
else if (steps == 0)
64-
; // Don't use the spaced formatting
6563
if (bIsDecimal)
6664
bOut += '.' + bDecimal;
67-
else if (steps == 0)
68-
; // Don't use the spaced formatting
6965

7066
if (aIsDecimal and not bIsDecimal and (steps != 0))
7167
bOut += std::string(aDecimal.length() + 1, ' ');
@@ -87,8 +83,8 @@ std::string reportAdd(const std::string& aInteger,
8783
ss << bChar << " ";
8884

8985
ss << '\n' << " ";
90-
for (const bool c : carries)
91-
if (c)
86+
for (const int c : carries)
87+
if (c != 0)
9288
ss << makeSubscript("1") << " ";
9389
else
9490
ss << " ";

src/calc/add/addReport.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ std::string reportAdd(const std::string& aInteger,
5454
const std::string& bInteger,
5555
const std::string& bDecimal,
5656
const std::vector<int>& sumDigits,
57-
const std::vector<bool>& carries,
57+
const std::vector<int>& carries,
5858
bool resultIsNegative,
5959
int steps,
6060
bool properlyFormat);

src/calc/division/division.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
#include <cstddef>
4040
#include <cstdlib>
41-
#include <ostream>
4241
#include <sstream>
4342
#include <string>
4443

@@ -56,7 +55,7 @@ namespace steppable::__internals::calc
5655
if (compare(currentRemainder, divisor, 0) == "0")
5756
return { "0", currentRemainder };
5857
if (compare(currentRemainder, divisor, 0) == "2")
59-
return { "1", "0" }; // Equal
58+
return { .quotient = "1", .remainder = "0" }; // Equal
6059

6160
int out = 0;
6261
while (compare(currentRemainder, divisor, 0) != "0")
@@ -279,7 +278,7 @@ namespace steppable::__internals::calc
279278
const auto nearestResult = multiply(divisor, quotient, 0);
280279
const auto& remainder = removeLeadingZeros(subtract(number, nearestResult, 0));
281280

282-
return { quotient, remainder };
281+
return { .quotient = quotient, .remainder = remainder };
283282
}
284283

285284
std::string getGCD(const std::string& _a, const std::string& _b)

src/calc/division/divisionReport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ std::string reportDivision(std::stringstream& tempFormattedAns,
5858
{
5959
tempFormattedAns << std::string(width - temp.length(), ' ') << makeWider(temp) << '\n';
6060
formattedAns << std::string(width - ans.length(), ' ') << makeWider(ans) << '\n';
61-
formattedAns << std::string(divisor.length() * 3 - 1, ' ');
62-
formattedAns << std::string(width - divisor.length() * 2, '_') << '\n';
61+
formattedAns << std::string((divisor.length() * 3) - 1, ' ');
62+
formattedAns << std::string(width - (divisor.length() * 2), '_') << '\n';
6363
formattedAns << tempFormattedAns.rdbuf();
6464

6565
formattedAns << THEREFORE << " ";

src/calc/log/log.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ namespace steppable::__internals::calc
6767
// x + 4x + 1 x + 4x + 1
6868
const auto& x2 = power(x, "2", 0);
6969
const auto& x2Minus1 = subtract(x2, "1", 0);
70-
const auto& numerator = multiply("3", x2Minus1, 0, decimals);
71-
const auto& fourX = multiply(x, "4", 0, decimals);
70+
const auto& numerator = multiply("3", x2Minus1, 0, static_cast<int>(decimals));
71+
const auto& fourX = multiply(x, "4", 0, static_cast<int>(decimals));
7272

7373
auto denominator = add(x2, fourX, 0);
7474
denominator = add(denominator, "1", 0);
@@ -95,7 +95,7 @@ namespace steppable::__internals::calc
9595
auto xMinusExpYN = subtract(x, expYN, 0);
9696
auto xPlusExpYN = add(x, expYN, 0);
9797
auto fraction = divide(xMinusExpYN, xPlusExpYN, 0, static_cast<int>(decimals));
98-
auto twoXFraction = multiply(fraction, "2", 0, decimals);
98+
auto twoXFraction = multiply(fraction, "2", 0, static_cast<int>(decimals));
9999
yn1 = add(yn, twoXFraction, 0);
100100
error = abs(subtract(yn, yn1, 0), 0);
101101
} while (compare(error, epsilon, 0) == "1");

0 commit comments

Comments
 (0)