amath  1.8.5
Simple command line calculator
real.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  * Project homepage:
26  * https://amath.innolan.net
27  *
28  */
29 
30 #ifndef AMATH_REAL_NUMBER_H
31 #define AMATH_REAL_NUMBER_H
32 
33 /**
34  * @file real.h
35  * @brief Class based handling of real numbers
36  */
37 
38 #include "numb.h"
39 
40 /**
41  * @brief Represent a real number with 15 significant digits
42  * @details
43  * Calculations are done using 64 bit IEEE 754 arithmetics.
44  */
45 struct RealNumber : public Number
46 {
47 public:
48  RealNumber();
49  explicit RealNumber(double x);
50  explicit RealNumber(signed int i);
51  explicit RealNumber(unsigned int i);
52  RealNumber(double x, bool round);
53  ~RealNumber();
54 
55  Number* Clone();
56  int GetIntegerValue();
57  double GetRealValue();
58  void SetRealValue(double value);
59  bool PureComplexValue();
60  int GetPrecedence();
62  bool IsNegative();
63  bool IsZero();
64  bool IsNaN();
65  bool IsInfinite();
66  bool IsNotImplemented();
67 
68  Number* Unary();
69  Number* Add(Number* other);
70  Number* Sub(Number* other);
71  Number* Mul(Number* other);
72  Number* Div(Number* other);
73  Number* Raise(Number* exponent);
74 
75  Number* Signum();
76  Number* Trunc();
77  Number* Round();
78  Number* Floor();
79  Number* Ceiling();
80  Number* Absolute();
81  Number* SquareRoot();
82  Number* CubeRoot();
83  Number* Reciprocal();
84  Number* Factorial();
85 
86  Number* Log();
87  Number* Log2();
88  Number* Log10();
89 
90  Number* Sine();
91  Number* Cosine();
92  Number* Tangent();
93  Number* Cosecant();
94  Number* Secant();
95  Number* Cotangent();
96  Number* Chord();
97  Number* ExSecant();
98  Number* ExCosecant();
99  Number* ArcSine();
100  Number* ArcCosine();
101  Number* ArcTangent();
102  Number* ArcCosecant();
103  Number* ArcCotangent();
104  Number* ArcSecant();
105  Number* ArcChord();
106  Number* ArcExSecant();
108 
109  Number* HypSine();
110  Number* HypCosine();
111  Number* HypTangent();
112  Number* HypCosecant();
113  Number* HypSecant();
114  Number* HypCotangent();
115  Number* HypArcSine();
116  Number* HypArcCosine();
119  Number* HypArcSecant();
121 
122  Number* VerSine();
123  Number* VerCosine();
124  Number* CoVerSine();
125  Number* CoVerCosine();
126  Number* HaVerSine();
127  Number* HaVerCosine();
128  Number* HaCoVerSine();
130 
131  Number* ArcVerSine();
132  Number* ArcVerCosine();
133  Number* ArcCoVerSine();
135  Number* ArcHaVerSine();
139 
140  friend struct ComplexNumber;
141 
142 private:
143  double x;
144 };
145 
146 #endif
Number * Clone()
Definition: real.cpp:85
Number * ArcChord()
Inverse trigonometric chord function for real numbers.
Definition: real.cpp:586
Number * Trunc()
Mathematical trunc function for real numbers.
Definition: real.cpp:284
Number * Log2()
Binary logarithm function (base 2) for real numbers.
Definition: real.cpp:378
Number * HypArcTangent()
Inverse hyperbolic tangent function for real numbers.
Definition: real.cpp:694
Number * ArcHaVerCosine()
Inverse haversed cosine function for real numbers.
Definition: real.cpp:871
Number * ArcExCosecant()
Inverse trigonometric excosecant function for real numbers.
Definition: real.cpp:604
Number * ArcHaCoVerCosine()
Inverse hacoversed cosine function for real numbers.
Definition: real.cpp:895
Number * HypSine()
Hyperbolic sine function for real numbers.
Definition: real.cpp:613
Number * Raise(Number *exponent)
Exponentiation function for real numbers.
Definition: real.cpp:257
Number * Tangent()
Trigonometric tangent function for real numbers.
Definition: real.cpp:451
Number * Log()
Natural logarithm function (base e) for real numbers.
Definition: real.cpp:397
Number * HaCoVerCosine()
Hacoversed cosine function for real numbers.
Definition: real.cpp:802
Number * Round()
Mathematical round function for real numbers.
Definition: real.cpp:293
Number * SquareRoot()
Square root function for real numbers.
Definition: real.cpp:329
Number * ArcHaCoVerSine()
Inverse hacoversed sine function for real numbers.
Definition: real.cpp:883
Number * ArcCosecant()
Inverse trigonometric cosecant function for real numbers.
Definition: real.cpp:562
Number * ArcTangent()
Inverse trigonometric tangent function for real numbers.
Definition: real.cpp:541
bool IsNegative()
Definition: real.cpp:120
bool IsInfinite()
Returns true if number is infinite.
Definition: real.cpp:150
Number * ArcSine()
Inverse trigonometric sine function for real numbers.
Definition: real.cpp:523
Number * Log10()
Base 10 logarithm function for real numbers.
Definition: real.cpp:415
Number * HypArcSine()
Inverse hyperbolic sine function for real numbers.
Definition: real.cpp:676
Number * HypCotangent()
Hyperbolic cotangent function for real numbers.
Definition: real.cpp:664
Number * Factorial()
Factorial function for real numbers.
Definition: real.cpp:369
Number * VerSine()
Versed sine function for real numbers.
Definition: real.cpp:739
Definition: numb.h:66
RealNumber(unsigned int i)
Definition: real.cpp:76
Number * ArcExSecant()
Inverse trigonometric exsecant function for real numbers.
Definition: real.cpp:595
Number * Secant()
Trigonometric secant function for real numbers.
Definition: real.cpp:460
int GetPrecedence()
Definition: real.cpp:110
Number * ArcVerCosine()
Inverse versed cosine function for real numbers.
Definition: real.cpp:823
Number * ExCosecant()
Trigonometric excosecant function for real numbers.
Definition: real.cpp:514
Number * CoVerSine()
Coversed sine function for real numbers.
Definition: real.cpp:757
Number * ArcSecant()
Inverse trigonometric secant function for real numbers.
Definition: real.cpp:550
Number * CoVerCosine()
Coversed cosine function for real numbers.
Definition: real.cpp:766
Number * HaVerCosine()
Haversed cosine function for real numbers.
Definition: real.cpp:784
Number * HypTangent()
Hyperbolic tangent function for real numbers.
Definition: real.cpp:631
Number * Add(Number *other)
Addition of two real numbers.
Definition: real.cpp:182
Represent a real number with 15 significant digits.
Definition: real.h:45
Number * ArcHaVerSine()
Inverse haversed sine function for real numbers.
Definition: real.cpp:859
RealNumber()
Definition: real.cpp:37
Number * Absolute()
Absolute value of number for real numbers.
Definition: real.cpp:320
Number * HypArcCosecant()
Inverse hyperbolic cosecant function for real numbers.
Definition: real.cpp:715
Number * Cotangent()
Trigonometric cotangent function for real numbers.
Definition: real.cpp:484
Number * ArcCosine()
Inverse trigonometric cosine function for real numbers.
Definition: real.cpp:532
bool IsNotImplemented()
Always returns false for real numbers.
Definition: real.cpp:166
Number * VerCosine()
Versed cosine function for real numbers.
Definition: real.cpp:748
double x
Definition: real.h:143
Number * Cosine()
Trigonometric cosine function for real numbers.
Definition: real.cpp:442
int GetIntegerValue()
Definition: real.cpp:90
Number * Mul(Number *other)
Multiplication of two real numbers.
Definition: real.cpp:219
Number * ArcVerSine()
Inverse versed sine function for real numbers.
Definition: real.cpp:811
Number * Div(Number *other)
Division of two real numbers.
Definition: real.cpp:236
Represent a complex number with 2 components of 15 significant digits.
Definition: cplex.h:46
Number * Cosecant()
Trigonometric cosecant function for real numbers.
Definition: real.cpp:472
RealNumber(signed int i)
Definition: real.cpp:71
Number * HypSecant()
Hyperbolic secant function for real numbers.
Definition: real.cpp:640
bool IsZero()
Returns true if number is zero.
Definition: real.cpp:130
Number * Signum()
Mathematical sign function for real numbers.
Definition: real.cpp:275
Number * HypArcCotangent()
Inverse hyperbolic cotangent function for real numbers.
Definition: real.cpp:727
Number * CubeRoot()
Cube root function for real numbers.
Definition: real.cpp:344
bool IsNaN()
Returns true if number is NaN.
Definition: real.cpp:140
RealNumber(double x)
Definition: real.cpp:42
RealNumber(double x, bool round)
Definition: real.cpp:47
Number * ArcCotangent()
Inverse trigonometric cotangent function for real numbers.
Definition: real.cpp:574
void SetRealValue(double value)
Definition: real.cpp:100
Number * ExSecant()
Trigonometric exsecant function for real numbers.
Definition: real.cpp:505
double GetRealValue()
Definition: real.cpp:95
int GetDefaultPrecedence()
Definition: real.cpp:115
Number * Reciprocal()
Reciprocal function for real numbers.
Definition: real.cpp:358
Number * ArcCoVerSine()
Inverse coversed sine function for real numbers.
Definition: real.cpp:835
Number * HaVerSine()
Haversed sine function for real numbers.
Definition: real.cpp:775
Number * Ceiling()
Mathematical ceiling function for real numbers.
Definition: real.cpp:311
Number * ArcCoVerCosine()
Inverse coversed cosine function for real numbers.
Definition: real.cpp:847
Number * HypArcCosine()
Inverse hyperbolic cosine function for real numbers.
Definition: real.cpp:685
Number * HypArcSecant()
Inverse hyperbolic secant function for real numbers.
Definition: real.cpp:703
bool PureComplexValue()
Definition: real.cpp:105
Number * HaCoVerSine()
Hacoversed sine function for real numbers.
Definition: real.cpp:793
~RealNumber()
Definition: real.cpp:81
Number * Sine()
Trigonometric sine function for real numbers.
Definition: real.cpp:433
Number * Floor()
Mathematical floor function for real numbers.
Definition: real.cpp:302
Number * Chord()
Trigonometric chord function for real numbers.
Definition: real.cpp:496
Number * HypCosine()
Hyperbolic cosine function for real numbers.
Definition: real.cpp:622
Number * Sub(Number *other)
Subtraction of two real numbers.
Definition: real.cpp:199
Number * Unary()
Change sign of real number.
Definition: real.cpp:174
Number * HypCosecant()
Hyperbolic cosecant function for real numbers.
Definition: real.cpp:652