activemq-cpp-3.9.5
Float.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_FLOAT_H_
19#define _DECAF_LANG_FLOAT_H_
20
21#include <decaf/util/Config.h>
22#include <decaf/lang/Number.h>
23#include <decaf/lang/String.h>
26#include <string>
27
28namespace decaf {
29namespace lang {
30
31 class DECAF_API Float : public Number,
32 public Comparable<Float>,
33 public Comparable<float> {
34 private:
35
36 float value;
37
38 public:
39
41 static const int SIZE;
42
44 static const float MAX_VALUE;
45
47 static const float MIN_VALUE;
48
50 static const float NaN;
51
53 static const float POSITIVE_INFINITY;
54
56 static const float NEGATIVE_INFINITY;
57
58 public:
59
63 Float(float value);
64
68 Float(double value);
69
73 Float(const String& value);
74
75 virtual ~Float() {}
76
85 virtual int compareTo(const Float& f) const;
86
91 bool equals(const Float& f) const {
92 return this->value == f.value;
93 }
94
100 virtual bool operator==(const Float& f) const {
101 return this->value == f.value;
102 }
103
110 virtual bool operator<(const Float& f) const {
111 return this->value < f.value;
112 }
113
122 virtual int compareTo(const float& f) const;
123
128 bool equals(const float& f) const {
129 return this->value == f;
130 }
131
137 virtual bool operator==(const float& f) const {
138 return this->value == f;
139 }
140
147 virtual bool operator<(const float& f) const {
148 return this->value < f;
149 }
150
154 std::string toString() const;
155
160 virtual double doubleValue() const {
161 return (double) this->value;
162 }
163
168 virtual float floatValue() const {
169 return this->value;
170 }
171
176 virtual unsigned char byteValue() const {
177 return (unsigned char) this->value;
178 }
179
184 virtual short shortValue() const {
185 return (short) this->value;
186 }
187
192 virtual int intValue() const {
193 return (int) this->value;
194 }
195
200 virtual long long longValue() const {
201 return (long long) this->value;
202 }
203
207 bool isInfinite() const;
208
212 bool isNaN() const;
213
214 public:
215 // Statics
216
227 static int compare(float f1, float f2);
228
250 static int floatToIntBits(float value);
251
277 static int floatToRawIntBits(float value);
278
296 static float intBitsToFloat(int bits);
297
302 static bool isInfinite(float value);
303
312 static bool isNaN(float value);
313
325 static float parseFloat(const String& value);
326
361 static std::string toHexString(float value);
362
397 static std::string toString(float value);
398
404 static Float valueOf(float value);
405
414 static Float valueOf(const String& value);
415
416 private:
417
418 static const unsigned int SINGLE_EXPONENT_MASK;
419 static const unsigned int SINGLE_MANTISSA_MASK;
420 static const unsigned int SINGLE_NAN_BITS;
421
422 };
423
424}}
425
426#endif /*_DECAF_LANG_FLOAT_H_*/
This interface imposes a total ordering on the objects of each class that implements it.
Definition Comparable.h:33
virtual int compareTo(const float &f) const
Compares this Float instance with another.
virtual unsigned char byteValue() const
Answers the byte value which the receiver represents.
Definition Float.h:176
static Float valueOf(float value)
Returns a Float instance representing the specified float value.
virtual ~Float()
Definition Float.h:75
static bool isNaN(float value)
Checks and returns whether the given float is equal to NaN.
Float(const String &value)
Float(double value)
virtual int compareTo(const Float &f) const
Compares this Float instance with another.
virtual bool operator==(const Float &f) const
Compares equality between this object and the one passed.
Definition Float.h:100
virtual double doubleValue() const
Answers the double value which the receiver represents.
Definition Float.h:160
static std::string toHexString(float value)
Returns a hexadecimal string representation of the float argument.
static float intBitsToFloat(int bits)
Returns the float value corresponding to a given bit representation.
bool equals(const float &f) const
Definition Float.h:128
static bool isInfinite(float value)
std::string toString() const
static const float MAX_VALUE
The maximum value that the primitive type can hold.
Definition Float.h:44
static float parseFloat(const String &value)
Returns a new float initialized to the value represented by the specified string, as performed by the...
Float(float value)
static const float NEGATIVE_INFINITY
Constant for Negative Infinity.
Definition Float.h:56
virtual bool operator<(const Float &f) const
Compares this object to another and returns true if this object is considered to be less than the one...
Definition Float.h:110
virtual long long longValue() const
Answers the long value which the receiver represents.
Definition Float.h:200
static int floatToIntBits(float value)
Returns a representation of the specified floating-point value according to the IEEE 754 floating-poi...
bool isNaN() const
virtual int intValue() const
Answers the int value which the receiver represents.
Definition Float.h:192
bool isInfinite() const
virtual float floatValue() const
Answers the float value which the receiver represents.
Definition Float.h:168
virtual short shortValue() const
Answers the short value which the receiver represents.
Definition Float.h:184
static const float NaN
Constant for the Not a Number Value.
Definition Float.h:50
static int compare(float f1, float f2)
Compares the two specified double values.
bool equals(const Float &f) const
Definition Float.h:91
virtual bool operator<(const float &f) const
Compares this object to another and returns true if this object is considered to be less than the one...
Definition Float.h:147
static std::string toString(float value)
Returns a string representation of the float argument.
static Float valueOf(const String &value)
Returns a Float instance that wraps a primitive float which is parsed from the string value passed.
static int floatToRawIntBits(float value)
Returns a representation of the specified floating-point value according to the IEEE 754 floating-poi...
static const float POSITIVE_INFINITY
Constant for Positive Infinity.
Definition Float.h:53
static const float MIN_VALUE
The minimum value that the primitive type can hold.
Definition Float.h:47
virtual bool operator==(const float &f) const
Compares equality between this object and the one passed.
Definition Float.h:137
static const int SIZE
The size in bits of the primitive int type.
Definition Float.h:41
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