• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kcalc/knumber
 

kcalc/knumber

  • kcalc
  • knumber
knumber.h
1/* This file is part of the KDE libraries
2 Copyright (C) 2005 Klaus Niederkrueger <kniederk@math.uni-koeln.de>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19#ifndef _KNUMBER_H
20#define _KNUMBER_H
21
22#include <tdelibs_export.h>
23
24#include "knumber_priv.h"
25
26class TQString;
27
62class TDE_EXPORT KNumber
63{
64 public:
65 static KNumber const Zero;
66 static KNumber const One;
67 static KNumber const MinusOne;
68 static KNumber const Pi;
69 static KNumber const Euler;
70 static KNumber const NotDefined;
71
86 enum NumType {SpecialType, IntegerType, FractionType, FloatType};
87
105 enum ErrorType {UndefinedNumber, Infinity, MinusInfinity};
106
107 KNumber(signed int num = 0);
108 KNumber(unsigned int num);
109 KNumber(signed long int num);
110 KNumber(unsigned long int num);
111 KNumber(unsigned long long int num);
112
113 KNumber(double num);
114
115 KNumber(KNumber const & num);
116
117 KNumber(TQString const & num);
118
119 ~KNumber()
120 {
121 delete _num;
122 }
123
124 KNumber const & operator=(KNumber const & num);
125
129 NumType type(void) const;
130
141 static void setDefaultFloatOutput(bool flag);
142
150 static void setDefaultFractionalInput(bool flag);
151
157 static void setDefaultFloatPrecision(unsigned int prec);
158
167 static void setSplitoffIntegerForFractionOutput(bool flag);
168
181 TQString const toTQString(int width = -1, int prec = -1) const;
182
190 KNumber const abs(void) const;
191
203 KNumber const sqrt(void) const;
204
218 KNumber const cbrt(void) const;
219
227 KNumber const integerPart(void) const;
228
229 KNumber const power(KNumber const &exp) const;
230
231 KNumber const operator+(KNumber const & arg2) const;
232 KNumber const operator -(void) const;
233 KNumber const operator-(KNumber const & arg2) const;
234 KNumber const operator*(KNumber const & arg2) const;
235 KNumber const operator/(KNumber const & arg2) const;
236 KNumber const operator%(KNumber const & arg2) const;
237
238 KNumber const operator&(KNumber const & arg2) const;
239 KNumber const operator|(KNumber const & arg2) const;
240 KNumber const operator<<(KNumber const & arg2) const;
241 KNumber const operator>>(KNumber const & arg2) const;
242
243 operator bool(void) const;
244 operator signed long int(void) const;
245 operator unsigned long int(void) const;
246 operator unsigned long long int(void) const;
247 operator double(void) const;
248
249 bool const operator==(KNumber const & arg2) const
250 { return (compare(arg2) == 0); }
251
252 bool const operator!=(KNumber const & arg2) const
253 { return (compare(arg2) != 0); }
254
255 bool const operator>(KNumber const & arg2) const
256 { return (compare(arg2) > 0); }
257
258 bool const operator<(KNumber const & arg2) const
259 { return (compare(arg2) < 0); }
260
261 bool const operator>=(KNumber const & arg2) const
262 { return (compare(arg2) >= 0); }
263
264 bool const operator<=(KNumber const & arg2) const
265 { return (compare(arg2) <= 0); }
266
267 KNumber & operator +=(KNumber const &arg);
268 KNumber & operator -=(KNumber const &arg);
269
270
271 //KNumber const toFloat(void) const;
272
273
274
275
276 private:
277 void simplifyRational(void);
278 int const compare(KNumber const & arg2) const;
279
280 _knumber *_num;
281 static bool _float_output;
282 static bool _fraction_input;
283 static bool _splitoffinteger_output;
284};
285
286
287
288#endif // _KNUMBER_H
KNumber
Class that provides arbitrary precision numbers.
Definition: knumber.h:63
KNumber::ErrorType
ErrorType
A KNumber that represents an error, i.e.
Definition: knumber.h:105
KNumber::NumType
NumType
KNumber tries to provide transparent access to the following type of numbers:
Definition: knumber.h:86

kcalc/knumber

Skip menu "kcalc/knumber"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kcalc/knumber

Skip menu "kcalc/knumber"
  • kcalc
  •   knumber
  • superkaramba
Generated for kcalc/knumber by doxygen 1.9.4
This website is maintained by Timothy Pearson.