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

kcalc/knumber

knumber.h
00001 // -*- c-basic-offset: 2 -*-
00002 /* This file is part of the KDE libraries
00003     Copyright (C) 2005 Klaus Niederkrueger <kniederk@math.uni-koeln.de>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 #ifndef _KNUMBER_H
00021 #define _KNUMBER_H
00022 
00023 #include <tdelibs_export.h>
00024 
00025 #include "knumber_priv.h"
00026 
00027 class TQString;
00028 
00063 class KDE_EXPORT KNumber
00064 {
00065  public:
00066   static KNumber const Zero;
00067   static KNumber const One;
00068   static KNumber const MinusOne;
00069   static KNumber const Pi;
00070   static KNumber const Euler;
00071   static KNumber const NotDefined;
00072 
00087   enum NumType {SpecialType, IntegerType, FractionType, FloatType};
00088 
00106   enum ErrorType {UndefinedNumber, Infinity, MinusInfinity};
00107 
00108   KNumber(signed int num = 0);
00109   KNumber(unsigned int num);  
00110   KNumber(signed long int num);
00111   KNumber(unsigned long int num);
00112   KNumber(unsigned long long int num);
00113 
00114   KNumber(double num);
00115 
00116   KNumber(KNumber const & num);
00117   
00118   KNumber(TQString const & num);
00119   
00120   ~KNumber()
00121   {
00122     delete _num;
00123   }
00124   
00125   KNumber const & operator=(KNumber const & num);
00126 
00130   NumType type(void) const;
00131 
00142   static void setDefaultFloatOutput(bool flag);
00143 
00151   static void setDefaultFractionalInput(bool flag);
00152 
00158   static void setDefaultFloatPrecision(unsigned int prec);
00159 
00168   static void setSplitoffIntegerForFractionOutput(bool flag);
00169 
00182   TQString const toTQString(int width = -1, int prec = -1) const;
00183   
00191   KNumber const abs(void) const;
00192 
00204   KNumber const sqrt(void) const;
00205 
00219   KNumber const cbrt(void) const;
00220 
00228   KNumber const integerPart(void) const;
00229 
00230   KNumber const power(KNumber const &exp) const;
00231 
00232   KNumber const operator+(KNumber const & arg2) const;
00233   KNumber const operator -(void) const;
00234   KNumber const operator-(KNumber const & arg2) const;
00235   KNumber const operator*(KNumber const & arg2) const;
00236   KNumber const operator/(KNumber const & arg2) const;
00237   KNumber const operator%(KNumber const & arg2) const;
00238 
00239   KNumber const operator&(KNumber const & arg2) const;
00240   KNumber const operator|(KNumber const & arg2) const;
00241   KNumber const operator<<(KNumber const & arg2) const;
00242   KNumber const operator>>(KNumber const & arg2) const;
00243 
00244   operator bool(void) const;
00245   operator signed long int(void) const;
00246   operator unsigned long int(void) const;
00247   operator unsigned long long int(void) const;
00248   operator double(void) const;
00249 
00250   bool const operator==(KNumber const & arg2) const
00251   { return (compare(arg2) == 0); }
00252 
00253   bool const operator!=(KNumber const & arg2) const
00254   { return (compare(arg2) != 0); }
00255 
00256   bool const operator>(KNumber const & arg2) const
00257   { return (compare(arg2) > 0); }
00258 
00259   bool const operator<(KNumber const & arg2) const
00260   { return (compare(arg2) < 0); }
00261 
00262   bool const operator>=(KNumber const & arg2) const
00263   { return (compare(arg2) >= 0); }
00264 
00265   bool const operator<=(KNumber const & arg2) const
00266   { return (compare(arg2) <= 0); }
00267 
00268   KNumber & operator +=(KNumber const &arg);
00269   KNumber & operator -=(KNumber const &arg);
00270 
00271 
00272   //KNumber const toFloat(void) const;
00273   
00274   
00275   
00276   
00277  private:
00278   void simplifyRational(void);
00279   int const compare(KNumber const & arg2) const;
00280   
00281   _knumber *_num;
00282   static bool _float_output;
00283   static bool _fraction_input;
00284   static bool _splitoffinteger_output;
00285 };
00286 
00287 
00288 
00289 #endif // _KNUMBER_H

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