activemq-cpp-3.8.2
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/Comparable.h>
25 #include <string>
26 
27 namespace decaf{
28 namespace lang{
29 
30  class DECAF_API Float : public Number,
31  public Comparable<Float>,
32  public Comparable<float> {
33  private:
34 
35  float value;
36 
37  public:
38 
40  static const int SIZE;
41 
43  static const float MAX_VALUE;
44 
46  static const float MIN_VALUE;
47 
49  static const float NaN;
50 
52  static const float POSITIVE_INFINITY;
53 
55  static const float NEGATIVE_INFINITY;
56 
57  public:
58 
62  Float( float value );
63 
67  Float( double value );
68 
72  Float( const std::string& value );
73 
74  virtual ~Float() {}
75 
84  virtual int compareTo( const Float& f ) const;
85 
90  bool equals( const Float& f ) const {
91  return this->value == f.value;
92  }
93 
99  virtual bool operator==( const Float& f ) const {
100  return this->value == f.value;
101  }
102 
109  virtual bool operator<( const Float& f ) const {
110  return this->value < f.value;
111  }
112 
121  virtual int compareTo( const float& f ) const;
122 
127  bool equals( const float& f ) const {
128  return this->value == f;
129  }
130 
136  virtual bool operator==( const float& f ) const {
137  return this->value == f;
138  }
139 
146  virtual bool operator<( const float& f ) const {
147  return this->value < f;
148  }
149 
153  std::string toString() const;
154 
159  virtual double doubleValue() const {
160  return (double)this->value;
161  }
162 
167  virtual float floatValue() const {
168  return this->value;
169  }
170 
175  virtual unsigned char byteValue() const {
176  return (unsigned char)this->value;
177  }
178 
183  virtual short shortValue() const {
184  return (short)this->value;
185  }
186 
191  virtual int intValue() const {
192  return (int)this->value;
193  }
194 
199  virtual long long longValue() const {
200  return (long long)this->value;
201  }
202 
206  bool isInfinite() const;
207 
211  bool isNaN() const;
212 
213  public: // Statics
214 
225  static int compare( float f1, float f2 );
226 
248  static int floatToIntBits( float value );
249 
275  static int floatToRawIntBits( float value );
276 
294  static float intBitsToFloat( int bits );
295 
300  static bool isInfinite( float value );
301 
306  static bool isNaN( float value );
307 
315  static float parseFloat( const std::string& value );
316 
351  static std::string toHexString( float value );
352 
384  static std::string toString( float value );
385 
391  static Float valueOf( float value );
392 
401  static Float valueOf( const std::string& value );
402 
403  private:
404 
405  static const unsigned int SINGLE_EXPONENT_MASK = 0x7F800000;
406  static const unsigned int SINGLE_MANTISSA_MASK = 0x007FFFFF;
407  static const unsigned int SINGLE_NAN_BITS = (SINGLE_EXPONENT_MASK | 0x00400000);
408 
409  };
410 
411 }}
412 
413 #endif /*_DECAF_LANG_FLOAT_H_*/
virtual bool operator==(const float &f) const
Compares equality between this object and the one passed.
Definition: Float.h:136
virtual float floatValue() const
Answers the float value which the receiver represents.
Definition: Float.h:167
bool equals(const float &f) const
Definition: Float.h:127
static const float NEGATIVE_INFINITY
Constant for Negative Infinity.
Definition: Float.h:55
static const float NaN
Constant for the Not a Number Value.
Definition: Float.h:49
virtual long long longValue() const
Answers the long value which the receiver represents.
Definition: Float.h:199
virtual short shortValue() const
Answers the short value which the receiver represents.
Definition: Float.h:183
The abstract class Number is the superclass of classes Byte, Double, Float, Integer, Long, and Short.
Definition: Number.h:35
virtual bool operator==(const Float &f) const
Compares equality between this object and the one passed.
Definition: Float.h:99
Definition: Float.h:30
virtual double doubleValue() const
Answers the double value which the receiver represents.
Definition: Float.h:159
bool equals(const Float &f) const
Definition: Float.h:90
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:109
#define DECAF_API
Definition: Config.h:29
static const float MAX_VALUE
The maximum value that the primitive type can hold.
Definition: Float.h:43
static const int SIZE
The size in bits of the primitive int type.
Definition: Float.h:40
static const float MIN_VALUE
The minimum value that the primitive type can hold.
Definition: Float.h:46
virtual unsigned char byteValue() const
Answers the byte value which the receiver represents.
Definition: Float.h:175
virtual int intValue() const
Answers the int value which the receiver represents.
Definition: Float.h:191
static const float POSITIVE_INFINITY
Constant for Positive Infinity.
Definition: Float.h:52
virtual ~Float()
Definition: Float.h:74
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:146
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