|
activemq-cpp-3.3.0
|
00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _DECAF_LANG_DOUBLE_H_ 00019 #define _DECAF_LANG_DOUBLE_H_ 00020 00021 #include <decaf/util/Config.h> 00022 #include <decaf/lang/Comparable.h> 00023 #include <decaf/lang/Number.h> 00024 #include <decaf/lang/exceptions/NumberFormatException.h> 00025 #include <string> 00026 00027 namespace decaf{ 00028 namespace lang{ 00029 00030 class DECAF_API Double : public Number, 00031 public Comparable<Double>, 00032 public Comparable<double> { 00033 private: 00034 00035 double value; 00036 00037 public: 00038 00040 static const int SIZE = 64; 00041 00043 static const double MAX_VALUE; 00044 00046 static const double MIN_VALUE; 00047 00049 static const double NaN; 00050 00052 static const double POSITIVE_INFINITY; 00053 00055 static const double NEGATIVE_INFINITY; 00056 00057 public: 00058 00065 Double( double value ); 00066 00077 Double( const std::string& value ); 00078 00079 virtual ~Double() {} 00080 00089 virtual int compareTo( const Double& d ) const; 00090 00095 bool equals( const Double& d ) const { 00096 return this->value == d.value; 00097 } 00098 00104 virtual bool operator==( const Double& d ) const { 00105 return this->value == d.value; 00106 } 00107 00114 virtual bool operator<( const Double& d ) const { 00115 return this->value < d.value; 00116 } 00117 00126 virtual int compareTo( const double& d ) const; 00127 00132 bool equals( const double& d ) const { 00133 return this->value == d; 00134 } 00135 00141 virtual bool operator==( const double& d ) const { 00142 return this->value == d; 00143 } 00144 00151 virtual bool operator<( const double& d ) const { 00152 return this->value < d; 00153 } 00154 00158 std::string toString() const; 00159 00164 virtual double doubleValue() const { 00165 return this->value; 00166 } 00167 00172 virtual float floatValue() const { 00173 return (float)this->value; 00174 } 00175 00180 virtual unsigned char byteValue() const { 00181 return (unsigned char)this->value; 00182 } 00183 00188 virtual short shortValue() const { 00189 return (short)this->value; 00190 } 00191 00196 virtual int intValue() const { 00197 return (int)this->value; 00198 } 00199 00204 virtual long long longValue() const { 00205 return (long long)this->value; 00206 } 00207 00211 bool isInfinite() const; 00212 00216 bool isNaN() const; 00217 00218 public: // Statics 00219 00231 static int compare( double d1, double d2 ); 00232 00255 static long long doubleToLongBits( double value ); 00256 00282 static long long doubleToRawLongBits( double value ); 00283 00288 static bool isInfinite( double value ); 00289 00294 static bool isNaN( double value ); 00295 00312 static double longBitsToDouble( long long bits ); 00313 00321 static double parseDouble( const std::string value ); 00322 00357 static std::string toHexString( double value ); 00358 00390 static std::string toString( double value ); 00391 00397 static Double valueOf( double value ); 00398 00406 static Double valueOf( const std::string& value ); 00407 00408 private: 00409 00410 static const long long DOUBLE_SIGN_MASK = 0x8000000000000000LL; 00411 static const long long DOUBLE_EXPONENT_MASK = 0x7FF0000000000000LL; 00412 static const long long DOUBLE_MANTISSA_MASK = 0x000FFFFFFFFFFFFFLL; 00413 static const long long DOUBLE_NAN_BITS = 00414 DOUBLE_EXPONENT_MASK | 0x0008000000000000LL; 00415 00416 }; 00417 00418 }} 00419 00420 #endif /*_DECAF_LANG_DOUBLE_H_*/