GY-63_MS5611/libraries/Fraction
2022-08-03 21:56:07 +02:00
..
.github add funding.yml 2022-08-03 21:56:07 +02:00
examples 0.1.13 Fraction 2021-12-18 14:11:39 +01:00
test 0.1.13 Fraction 2021-12-18 14:11:39 +01:00
.arduino-ci.yml 0.1.12 Fraction 2021-11-01 15:56:22 +01:00
fraction.cpp 0.1.13 Fraction 2021-12-18 14:11:39 +01:00
fraction.h 0.1.13 Fraction 2021-12-18 14:11:39 +01:00
keywords.txt 0.1.13 Fraction 2021-12-18 14:11:39 +01:00
library.json 0.1.13 Fraction 2021-12-18 14:11:39 +01:00
library.properties 0.1.13 Fraction 2021-12-18 14:11:39 +01:00
LICENSE 0.1.13 Fraction 2021-12-18 14:11:39 +01:00
readme.md 0.1.13 Fraction 2021-12-18 14:11:39 +01:00

Arduino CI Arduino-lint JSON check License: MIT GitHub release

Fraction

Arduino library to implement a Fraction data type (experimental).

Description

The fraction library implements fractional numbers a.k.a. Q, (integers are Z and floats/doubles are R), and the conversion to floats.

The code is working with a number of limitations among others:

  • denominator is max 4 digits to keep code for multiply and divide simple
  • Fractions are not exact (even floats are not exact)
  • the range of numbers supported is limited.
  • code is experimental still.

That said, the library is useful e.g. to display float numbers as a fraction. From programming point of view the fractionize() function, converting a double into a fraction is a nice programming problem, fast with a minimal error.

In short, use fractions with care otherwise your sketch might get broken ;)

Operations

See examples

Use with care

The library is reasonably tested, and if problems arise please let me know.

Future

  • improve documentation
  • extend unit tests
  • experiment with bigger nominator/denominator using all of 32767 possibilities ?
  • investigate divide by zero errors
  • investigate better fractionize() - depends on nom/denom size
  • test test test ...
  • add famous constants as Fraction e.g FRAC_PI = (355, 113) ??