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>
23#include <decaf/lang/Number.h>
24#include <decaf/lang/String.h>
26#include <string>
27
28namespace decaf {
29namespace 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_*/
This interface imposes a total ordering on the objects of each class that implements it.
Definition Comparable.h:33
virtual int compareTo(const double &d) const
Compares this Double instance with another.
virtual short shortValue() const
Answers the short value which the receiver represents.
Definition Double.h:189
virtual double doubleValue() const
Answers the double value which the receiver represents.
Definition Double.h:165
bool equals(const double &d) const
Definition Double.h:133
static const double NaN
Constant for the Not a Number Value.
Definition Double.h:50
static const double MAX_VALUE
The maximum value that the primitive type can hold.
Definition Double.h:44
static Double valueOf(const String &value)
Returns a Double instance that wraps a primitive double which is parsed from the string value passed.
static const double MIN_VALUE
The minimum value that the primitive type can hold.
Definition Double.h:47
static const double NEGATIVE_INFINITY
Constant for Negative Infinitiy.
Definition Double.h:56
static const double POSITIVE_INFINITY
Constant for Positive Infinity.
Definition Double.h:53
Double(double value)
Constructs a new instance of a Double object and assigns it the given value.
static bool isNaN(double value)
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
std::string toString() const
bool isNaN() const
virtual long long longValue() const
Answers the long value which the receiver represents.
Definition Double.h:205
static std::string toHexString(double value)
Returns a hexadecimal string representation of the double argument.
virtual bool operator==(const Double &d) const
Compares equality between this object and the one passed.
Definition Double.h:105
virtual int compareTo(const Double &d) const
Compares this Double instance with another.
virtual unsigned char byteValue() const
Answers the byte value which the receiver represents.
Definition Double.h:181
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
bool isInfinite() const
static bool isInfinite(double value)
static std::string toString(double value)
Returns a string representation of the double argument.
static double parseDouble(const String &value)
Returns a new double initialized to the value represented by the specified string,...
static Double valueOf(double value)
Returns a Double instance representing the specified double value.
static int compare(double d1, double d2)
Compares the two specified double values.
static const int SIZE
The size in bits of the primitive int type.
Definition Double.h:41
static long long doubleToRawLongBits(double value)
Returns a representation of the specified floating-point value according to the IEEE 754 floating-poi...
bool equals(const Double &d) const
Definition Double.h:96
virtual float floatValue() const
Answers the float value which the receiver represents.
Definition Double.h:173
static long long doubleToLongBits(double value)
Returns a representation of the specified floating-point value according to the IEEE 754 floating-poi...
virtual ~Double()
Definition Double.h:80
virtual bool operator==(const double &d) const
Compares equality between this object and the one passed.
Definition Double.h:142
Double(const String &value)
Constructs a new Double and attempts to convert the given string to a double value,...
virtual int intValue() const
Answers the int value which the receiver represents.
Definition Double.h:197
static double longBitsToDouble(long long bits)
Returns the double value corresponding to a given bit representation.
The abstract class Number is the superclass of classes Byte, Double, Float, Integer,...
Definition Number.h:35
An immutable sequence of characters.
Definition String.h:57
#define DECAF_API
Definition Config.h:29
Definition ThreadingTypes.h:31
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25