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

kcalc/knumber

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

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.8.11
This website is maintained by Timothy Pearson.