Description Usage Arguments Details Note Author(s) See Also Examples

Create, coerce to or test for a Brobdingnagian object

1 2 3 |

`x` |
Quantity to be tested, coerced in to Brobdingnagian form |

`positive` |
In function |

Function `as.brob()`

is the user's workhorse: use this to coerce
numeric vectors to `brob`

s.

Function `is.brob()`

tests for its arguments being of class
`brob`

.

Function `brob()`

takes argument `x`

and returns a `brob`

formally equal to *exp(x)*; set argument `positive`

to
`FALSE`

to return *-exp(x)*. Thus calling function
`exp(x)`

simply returns `brob(x)`

. This function is not
really intended for the end user: it is confusing and includes no
argument checking. In general numerical work, use function
`as.brob()`

instead, although be aware that if you really really
want *e^1e7*, you should use `brob(1e7)`

;
this would be an **exact** representation.

Real numbers are represented by two objects: a real, holding the
logarithm of their absolute values; and a logical, indicating the
sign. Multiplication and exponentiation are easy: the challenge is
addition. This is achieved using the (trivial) identity
*log(e^x+e^y)=x+log(1+e^(y-x))*
where, WLOG, *y<x*.

Complex numbers are stored as a pair of `brob`

s: objects of class
`glub`

.

The package is a simple example of S4 methods. However, it
*could* be viewed as a cautionary tale: the underlying **R**
concepts are easy yet the S4 implementation is long and difficult. I
would not recommend using S4 methods for a package as simple as this;
S3 methods would have been perfectly adequate. I would suggest that
S4 methods should only be used when S3 methods are *demonstrably*
inadequate.

The package has poor handling of `NA`

and `NaN`

. Currently,
`as.brob(1) + as.brob(c(1,NA))`

returns an error.

Robin K. S, Hankin

1 2 3 4 5 6 7 8 9 |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.