README.md

rational

A rational number class using a variety of class systems

R-CMD-CHECK Coverage status

Rational Website

Why a Rational Package?

This package serves 2 purposes:

> # expectations dashed
> (0.1 + 0.2) == 0.3
[1] FALSE
> # what?
> print(0.1 + 0.2, digits = 20)
[1] 0.30000000000000004
> # what am I supposed to do in R? (or any other floating point arithmetic system)
> all.equal(0.1 + 0.2, 0.3, tolerance = 1E-9)
[1] TRUE
> abs(0.1 + 0.2 - 0.3) < 1E-9
[1] TRUE
> # is there another way?  Yes, rational numbers
> #   NOTE: the "L" notation indicates an integer
> rational(1L, 10L) + rational(2L, 10L) == rational(3L, 10L)
[1] TRUE


bertcarnell/rational documentation built on May 10, 2021, 8:32 p.m.