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>
24 #include <decaf/lang/Comparable.h>
26 #include <string>
27 
28 namespace decaf {
29 namespace 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_*/
virtual int intValue() const
Answers the int value which the receiver represents.
Definition: Float.h:192
virtual bool operator==(const Float &f) const
Compares equality between this object and the one passed.
Definition: Float.h:100
bool equals(const Float &f) const
Definition: Float.h:91
virtual float floatValue() const
Answers the float value which the receiver represents.
Definition: Float.h:168
static const float NEGATIVE_INFINITY
Constant for Negative Infinity.
Definition: Float.h:56
static const float NaN
Constant for the Not a Number Value.
Definition: Float.h:50
virtual long long longValue() const
Answers the long value which the receiver represents.
Definition: Float.h:200
The abstract class Number is the superclass of classes Byte, Double, Float, Integer, Long, and Short.
Definition: Number.h:35
Definition: Float.h:31
virtual short shortValue() const
Answers the short value which the receiver represents.
Definition: Float.h:184
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
An immutable sequence of characters.
Definition: String.h:57
#define DECAF_API
Definition: Config.h:29
static const float MAX_VALUE
The maximum value that the primitive type can hold.
Definition: Float.h:44
static const int SIZE
The size in bits of the primitive int type.
Definition: Float.h:41
static const float MIN_VALUE
The minimum value that the primitive type can hold.
Definition: Float.h:47
virtual unsigned char byteValue() const
Answers the byte value which the receiver represents.
Definition: Float.h:176
static const float POSITIVE_INFINITY
Constant for Positive Infinity.
Definition: Float.h:53
virtual ~Float()
Definition: Float.h:75
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 double doubleValue() const
Answers the double value which the receiver represents.
Definition: Float.h:160
bool equals(const float &f) const
Definition: Float.h:128
virtual bool operator==(const float &f) const
Compares equality between this object and the one passed.
Definition: Float.h:137
This interface imposes a total ordering on the objects of each class that implements it...
Definition: Comparable.h:33