activemq-cpp-3.8.2
Double.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_LANG_DOUBLE_H_
19 #define _DECAF_LANG_DOUBLE_H_
20 
21 #include <decaf/util/Config.h>
22 #include <decaf/lang/Comparable.h>
23 #include <decaf/lang/Number.h>
25 #include <string>
26 
27 namespace decaf{
28 namespace lang{
29 
30  class DECAF_API Double : public Number,
31  public Comparable<Double>,
32  public Comparable<double> {
33  private:
34 
35  double value;
36 
37  public:
38 
40  static const int SIZE;
41 
43  static const double MAX_VALUE;
44 
46  static const double MIN_VALUE;
47 
49  static const double NaN;
50 
52  static const double POSITIVE_INFINITY;
53 
55  static const double NEGATIVE_INFINITY;
56 
57  public:
58 
65  Double( double value );
66 
77  Double( const std::string& value );
78 
79  virtual ~Double() {}
80 
89  virtual int compareTo( const Double& d ) const;
90 
95  bool equals( const Double& d ) const {
96  return this->value == d.value;
97  }
98 
104  virtual bool operator==( const Double& d ) const {
105  return this->value == d.value;
106  }
107 
114  virtual bool operator<( const Double& d ) const {
115  return this->value < d.value;
116  }
117 
126  virtual int compareTo( const double& d ) const;
127 
132  bool equals( const double& d ) const {
133  return this->value == d;
134  }
135 
141  virtual bool operator==( const double& d ) const {
142  return this->value == d;
143  }
144 
151  virtual bool operator<( const double& d ) const {
152  return this->value < d;
153  }
154 
158  std::string toString() const;
159 
164  virtual double doubleValue() const {
165  return this->value;
166  }
167 
172  virtual float floatValue() const {
173  return (float)this->value;
174  }
175 
180  virtual unsigned char byteValue() const {
181  return (unsigned char)this->value;
182  }
183 
188  virtual short shortValue() const {
189  return (short)this->value;
190  }
191 
196  virtual int intValue() const {
197  return (int)this->value;
198  }
199 
204  virtual long long longValue() const {
205  return (long long)this->value;
206  }
207 
211  bool isInfinite() const;
212 
216  bool isNaN() const;
217 
218  public: // Statics
219 
231  static int compare( double d1, double d2 );
232 
255  static long long doubleToLongBits( double value );
256 
282  static long long doubleToRawLongBits( double value );
283 
288  static bool isInfinite( double value );
289 
294  static bool isNaN( double value );
295 
312  static double longBitsToDouble( long long bits );
313 
321  static double parseDouble( const std::string value );
322 
357  static std::string toHexString( double value );
358 
390  static std::string toString( double value );
391 
397  static Double valueOf( double value );
398 
406  static Double valueOf( const std::string& value );
407 
408  private:
409 
410  static const long long DOUBLE_SIGN_MASK = 0x8000000000000000LL;
411  static const long long DOUBLE_EXPONENT_MASK = 0x7FF0000000000000LL;
412  static const long long DOUBLE_MANTISSA_MASK = 0x000FFFFFFFFFFFFFLL;
413  static const long long DOUBLE_NAN_BITS =
414  DOUBLE_EXPONENT_MASK | 0x0008000000000000LL;
415 
416  };
417 
418 }}
419 
420 #endif /*_DECAF_LANG_DOUBLE_H_*/
static const double NEGATIVE_INFINITY
Constant for Negative Infinitiy.
Definition: Double.h:55
virtual long long longValue() const
Answers the long value which the receiver represents.
Definition: Double.h:204
virtual int intValue() const
Answers the int value which the receiver represents.
Definition: Double.h:196
bool equals(const Double &d) const
Definition: Double.h:95
static const double MAX_VALUE
The maximum value that the primitive type can hold.
Definition: Double.h:43
virtual bool operator==(const double &d) const
Compares equality between this object and the one passed.
Definition: Double.h:141
virtual bool operator<(const double &d) const
Compares this object to another and returns true if this object is considered to be less than the one...
Definition: Double.h:151
Definition: Double.h:30
virtual bool operator==(const Double &d) const
Compares equality between this object and the one passed.
Definition: Double.h:104
static const double MIN_VALUE
The minimum value that the primitive type can hold.
Definition: Double.h:46
static const double POSITIVE_INFINITY
Constant for Positive Infinity.
Definition: Double.h:52
The abstract class Number is the superclass of classes Byte, Double, Float, Integer, Long, and Short.
Definition: Number.h:35
virtual unsigned char byteValue() const
Answers the byte value which the receiver represents.
Definition: Double.h:180
virtual bool operator<(const Double &d) const
Compares this object to another and returns true if this object is considered to be less than the one...
Definition: Double.h:114
virtual double doubleValue() const
Answers the double value which the receiver represents.
Definition: Double.h:164
#define DECAF_API
Definition: Config.h:29
static const double NaN
Constant for the Not a Number Value.
Definition: Double.h:49
bool equals(const double &d) const
Definition: Double.h:132
virtual float floatValue() const
Answers the float value which the receiver represents.
Definition: Double.h:172
virtual ~Double()
Definition: Double.h:79
static const int SIZE
The size in bits of the primitive int type.
Definition: Double.h:40
virtual short shortValue() const
Answers the short value which the receiver represents.
Definition: Double.h:188
This interface imposes a total ordering on the objects of each class that implements it...
Definition: Comparable.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25