calculator/src/CalcManager/Header Files/RationalMath.h
Rudy Huyn 7a7ceb5888 Modify how modulo is calculated in Normal and Scientific mode. (#412)
## Fixes #111

> The modulo operator on this calculator gives the result that is different to the most used calculators.

The current `modrate` function is the equivalent of rem(...)/remainder(...), not mod(...)/modulo(...) available in some popular Math apps. 

### Description of the changes:
- rename `modrate` in `remrate` to be more accurate.
- add `modrate`, calculating modulo similarly to Matlab, Bing, Google calculator, Maxima, Wolfram Alpha and Microsoft Excel 
- Add `RationalMath::Mod` using `modrate` as an alternative to `Rational::operator%` using `remrate`
- Add a helper `SIGN` to retrieve the sign of a `Rational`.
- modify `CalcEngine` to use `modrate` in Normal and Scientific mode and `remrate` in Programmer mode.

### How changes were validated:
- manually and unit tests added
2019-04-16 17:17:24 -07:00

39 lines
1.3 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "Rational.h"
namespace CalcEngine::RationalMath
{
Rational Frac(Rational const& rat);
Rational Integer(Rational const& rat);
Rational Pow(Rational const& base, Rational const& pow);
Rational Root(Rational const& base, Rational const& root);
Rational Fact(Rational const& rat);
Rational Mod(Rational const& a, Rational const& b);
Rational Exp(Rational const& rat);
Rational Log(Rational const& rat);
Rational Log10(Rational const& rat);
Rational Invert(Rational const& rat);
Rational Abs(Rational const& rat);
Rational Sin(Rational const& rat, ANGLE_TYPE angletype);
Rational Cos(Rational const& rat, ANGLE_TYPE angletype);
Rational Tan(Rational const& rat, ANGLE_TYPE angletype);
Rational ASin(Rational const& rat, ANGLE_TYPE angletype);
Rational ACos(Rational const& rat, ANGLE_TYPE angletype);
Rational ATan(Rational const& rat, ANGLE_TYPE angletype);
Rational Sinh(Rational const& rat);
Rational Cosh(Rational const& rat);
Rational Tanh(Rational const& rat);
Rational ASinh(Rational const& rat);
Rational ACosh(Rational const& rat);
Rational ATanh(Rational const& rat);
}