activemq-cpp-3.9.5
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>
24 #include <decaf/lang/String.h>
26 #include <string>
27 
28 namespace decaf {
29 namespace lang {
30 
31  class DECAF_API Double : public Number,
32  public Comparable<Double>,
33  public Comparable<double> {
34  private:
35 
36  double value;
37 
38  public:
39 
41  static const int SIZE;
42 
44  static const double MAX_VALUE;
45 
47  static const double MIN_VALUE;
48 
50  static const double NaN;
51 
53  static const double POSITIVE_INFINITY;
54 
56  static const double NEGATIVE_INFINITY;
57 
58  public:
59 
66  Double(double value);
67 
78  Double(const String& value);
79 
80  virtual ~Double() {}
81 
90  virtual int compareTo(const Double& d) const;
91 
96  bool equals(const Double& d) const {
97  return this->value == d.value;
98  }
99 
105  virtual bool operator==(const Double& d) const {
106  return this->value == d.value;
107  }
108 
115  virtual bool operator<(const Double& d) const {
116  return this->value < d.value;
117  }
118 
127  virtual int compareTo(const double& d) const;
128 
133  bool equals(const double& d) const {
134  return this->value == d;
135  }
136 
142  virtual bool operator==(const double& d) const {
143  return this->value == d;
144  }
145 
152  virtual bool operator<(const double& d) const {
153  return this->value < d;
154  }
155 
159  std::string toString() const;
160 
165  virtual double doubleValue() const {
166  return this->value;
167  }
168 
173  virtual float floatValue() const {
174  return (float) this->value;
175  }
176 
181  virtual unsigned char byteValue() const {
182  return (unsigned char) this->value;
183  }
184 
189  virtual short shortValue() const {
190  return (short) this->value;
191  }
192 
197  virtual int intValue() const {
198  return (int) this->value;
199  }
200 
205  virtual long long longValue() const {
206  return (long long) this->value;
207  }
208 
212  bool isInfinite() const;
213 
217  bool isNaN() const;
218 
219  public:
220 
232  static int compare(double d1, double d2);
233 
256  static long long doubleToLongBits(double value);
257 
283  static long long doubleToRawLongBits(double value);
284 
289  static bool isInfinite(double value);
290 
295  static bool isNaN(double value);
296 
313  static double longBitsToDouble(long long bits);
314 
326  static double parseDouble(const String& value);
327 
362  static std::string toHexString(double value);
363 
395  static std::string toString(double value);
396 
405  static Double valueOf(double value);
406 
418  static Double valueOf(const String& value);
419 
420  private:
421 
422  static const long long DOUBLE_SIGN_MASK;
423  static const long long DOUBLE_EXPONENT_MASK;
424  static const long long DOUBLE_MANTISSA_MASK;
425  static const long long DOUBLE_NAN_BITS;
426 
427  };
428 
429 }}
430 
431 #endif /*_DECAF_LANG_DOUBLE_H_*/
virtual unsigned char byteValue() const
Answers the byte value which the receiver represents.
Definition: Double.h:181
static const double NEGATIVE_INFINITY
Constant for Negative Infinitiy.
Definition: Double.h:56
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:115
static const double MAX_VALUE
The maximum value that the primitive type can hold.
Definition: Double.h:44
bool equals(const Double &d) const
Definition: Double.h:96
Definition: Double.h:31
static const double MIN_VALUE
The minimum value that the primitive type can hold.
Definition: Double.h:47
static const double POSITIVE_INFINITY
Constant for Positive Infinity.
Definition: Double.h:53
virtual short shortValue() const
Answers the short value which the receiver represents.
Definition: Double.h:189
The abstract class Number is the superclass of classes Byte, Double, Float, Integer, Long, and Short.
Definition: Number.h:35
bool equals(const double &d) const
Definition: Double.h:133
virtual bool operator==(const double &d) const
Compares equality between this object and the one passed.
Definition: Double.h:142
virtual double doubleValue() const
Answers the double value which the receiver represents.
Definition: Double.h:165
virtual int intValue() const
Answers the int value which the receiver represents.
Definition: Double.h:197
An immutable sequence of characters.
Definition: String.h:57
#define DECAF_API
Definition: Config.h:29
virtual bool operator==(const Double &d) const
Compares equality between this object and the one passed.
Definition: Double.h:105
static const double NaN
Constant for the Not a Number Value.
Definition: Double.h:50
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:152
virtual ~Double()
Definition: Double.h:80
static const int SIZE
The size in bits of the primitive int type.
Definition: Double.h:41
This interface imposes a total ordering on the objects of each class that implements it...
Definition: Comparable.h:33
virtual long long longValue() const
Answers the long value which the receiver represents.
Definition: Double.h:205
virtual float floatValue() const
Answers the float value which the receiver represents.
Definition: Double.h:173