Skip to content

Commit

Permalink
fix build-CI
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Apr 23, 2024
1 parent f71b915 commit b392817
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ Serial.print(fr.toString()); // prints "(355/113)"
```


#### Related




## Interface

```cpp
Expand Down
15 changes: 11 additions & 4 deletions examples/fraction_extensive/fraction_extensive.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@


// step size to test, typical 100000
// AVR UNO takes a bit less than 500 seconds
// to process 100.000 tests
// for 100.000 tests
// - AVR UNO 16 MHz takes ~500 seconds at 115200 baud
// - ESP32 240 MHz takes ~400 seconds at 115200 baud
// - ESP32 240 MHz takes ~85 seconds at 500000 baud

const uint32_t N = 100000;

Expand All @@ -20,16 +22,21 @@ uint32_t pos = 0;

void setup()
{
Serial.begin(115200);
// NOTE BAUDRATE!
Serial.begin(500000);
Serial.print(__FILE__);
Serial.print("FRACTION_LIB_VERSION: ");
Serial.println(FRACTION_LIB_VERSION);
Serial.println();
delay(100);

Fraction pi(PI);
Serial.println(pi.toString());
delay(1000);

start = millis();

for (uint32_t n = 10; n <= N; n++)
for (uint32_t n = 100; n <= N; n++)
{
float g = n * (1.0 / N);
Fraction frac( g );
Expand Down
6 changes: 3 additions & 3 deletions fraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void Fraction::simplify()
// in preventing overflow
while (q > 10000)
{
// rounding might need improvement
// rounding need improvement
p = (p + 5)/10;
q = (q + 5)/10;
x = gcd(p, q);
Expand Down Expand Up @@ -412,7 +412,7 @@ void Fraction::fractionize(float val)
int32_t count = (int32_t)test; // "N"
int32_t n = (count + 1) * low.n + high.n;
int32_t d = (count + 1) * low.d + high.d;
if ((n > 0x10000) || (d > 0x10000))
if ((n > 0x8000) || (d > 0x10000)) // 0x8000 0x10000
break;
high.n = n - low.n; // new "A"
high.d = d - low.d;
Expand All @@ -425,7 +425,7 @@ void Fraction::fractionize(float val)
int32_t count = (int32_t)test; // "N"
int32_t n = low.n + (count + 1) * high.n;
int32_t d = low.d + (count + 1) * high.d;
if ((n > 0x10000) || (d > 0x10000))
if ((n > 0x10000) || (d > 0x10000)) // 0x10000 0x10000
break;
low.n = n - high.n; // new "A"
low.d = d - high.d;
Expand Down
4 changes: 2 additions & 2 deletions test/unit_test_001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ unittest_teardown()
unittest(test_constructor)
{
Fraction pi(PI);
assertEqualFloat(PI, pi.toFloat(), 0.0001)
assertEqualFloat(PI, pi.toFloat(), 0.0001);
// what we wished it would find.
// assertEqual(355, pi.nominator());
// assertEqual(113, pi.denominator());
Expand All @@ -54,7 +54,7 @@ unittest(test_constructor)
fprintf(stderr, "pi %1.8f\n", pi.toFloat());

Fraction ee(EULER);
assertEqualFloat(EULER, ee.toFloat(), 0.0001)
assertEqualFloat(EULER, ee.toFloat(), 0.0001);
// what we wished it would find.
// assertEqual(3985, ee.nominator());
// assertEqual(1466, ee.denominator());
Expand Down

0 comments on commit b392817

Please sign in to comment.