Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ixlib_numconv.hh

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //  Description      : Numeric conversions
00003 // ----------------------------------------------------------------------------
00004 //  (c) Copyright 1999 by iXiONmedia, all rights reserved.
00005 // ----------------------------------------------------------------------------
00006 
00007 
00008 
00009 
00010 #ifndef IXLIB_NUMCONV
00011 #define IXLIB_NUMCONV
00012 
00013 
00014 
00015 
00016 #include <ixlib_base.hh>
00017 #include <ixlib_string.hh>
00018 
00019 
00020 
00021 
00022 // Macros ---------------------------------------------------------------------
00023 #define IXLIB_NUMCHARS          "0123456789ABCDEF"
00024 
00025 
00026 
00027 
00028 // Functions ------------------------------------------------------------------
00029 namespace ixion {
00030   std::string float2dec(double value);
00031   std::string float2dec(double value,unsigned int precision);
00032   std::string unsigned2base(unsigned long value,char digits = 0,char radix = 10);
00033   inline std::string unsigned2dec(unsigned long value,char digits = 0)
00034     { return unsigned2base(value,digits,10); }
00035   inline std::string unsigned2hex(unsigned long value,char digits = 0)
00036     { return unsigned2base(value,digits,16); }
00037   inline std::string unsigned2bin(unsigned long value,char digits = 0)
00038     { return unsigned2base(value,digits,2); }
00039   inline std::string unsigned2oct(unsigned long value,char digits = 0)
00040     { return unsigned2base(value,digits,8); }
00041   std::string signed2base(signed long value,char digits = 0,char radix = 10);
00042   inline std::string signed2dec(signed long value,char digits = 0)
00043     { return signed2base(value,digits,10); }
00044   inline std::string signed2hex(signed long value,char digits = 0)
00045     { return signed2base(value,digits,16); }
00046   inline std::string signed2bin(signed long value,char digits = 0)
00047     { return signed2base(value,digits,2); }
00048   inline std::string signed2oct(signed long value,char digits = 0)
00049     { return signed2base(value,digits,8); }
00050   
00051   std::string bytes2dec(TSize bytes);
00052   
00053   unsigned long evalNumeral(std::string const &numeral,unsigned radix = 10);
00054   double evalFloat(std::string const &numeral);
00055   unsigned long evalUnsigned(std::string const &numeral,unsigned default_base = 10);
00056   signed long evalSigned(std::string const &numeral,unsigned default_base = 10);
00057   }
00058 
00059 
00060 
00061 
00062 #endif

Generated on Wed Oct 31 17:12:24 2001 for ixlib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001