[![Actions Status](https://github.com/tbrowder/Math-FractionalPart/workflows/test/badge.svg)](https://github.com/tbrowder/Math-FractionalPart/actions)
NAME
====
Math::FractionalPart provides several routines to operate with the fractional parts of a number
SYNOPSIS
========
```raku
use Math::FractionalPart :afrac;
say (afrac -3.2); # Output <<0.2>>
say (frac -3.2); # Output <<-0.2>>
```
DESCRIPTION
===========
There are three different algebraic functions that operate on numbers and return their fractional parts. They all return the same result when operating on non-negative numbers, but all three return different results when operating on negative numbers. See the following references:
* 1. Wikipedia article on [Fractional Part](https://en.m.wikipedia.org/wiki/Fractional_part)
* 2. Wolfram article on [Fractional Part](https://mathworld.wolfram.com/FractionalPart.html)
* 3. *Celestial Calculations: A Gentle Introduction to Computational Astronomy*, J. L. Lawrence, 2018, MIT Press.
The following table shows the routines that have been implemented in this module.
Name | Raku formul | Example | Notes |
frac | x - floor(x) | frac(-1.3): 0.7 | 1 |
afrac | abs(x) - floor(abs(x)) | afrac(-1.3): 0.3 | 2 |
ofrac | x - floor(abs(x)) * sign(x) | ofrac(-1.3): -0.3 | 3 |
(NOTE: The table below will show incorrectly until `mi6` has the capability to implement more Unicode symbols.)
Name | Formula | Example | Notes |
frac | x - E<0x230a;>xE<0x230b> | frac(-1.3): 0.7 | 1 |
afrac | |x| - E<0x230a>|x|E<0x230b> | afrac(-1.3): 0.3 | 2 |
ofrac | x - E<0x230a>|x|E<0x230b>E<0x22c5>sign(x) | ofrac(-1.3): -0.3 | 3 |
Notes
* 1. See Ref 1, *frac* version 1 (per Graham, Knuth, et alii, 1992).
* 2. See Ref 1, *frac* version 2 (per Dainith, 2004); Ref 3, p. 7. Consider mnemonic 'a' for 'absolute value' or 'astronomical'.
* 3. See Ref 1, *frac* version 3 (an *odd function*); Ref 2: Wolfram's *FractionPart* function. Consider mnemonic 'o' for 'odd function'.
AUTHOR
======
Tom Browder
COPYRIGHT AND LICENSE
=====================
© 2021 Tom Browder
This library is free software; you can redistribute it or modify it under the Artistic License 2.0.