2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FBaseFloat.cpp
19 * @brief This is the implementation file for Float class.
30 #include <FBaseFloat.h>
31 #include <FBaseResult.h>
32 #include <FBaseSysLog.h>
33 #include "FBase_LocalizedNumParser.h"
35 namespace Tizen { namespace Base
41 FloatBitRep(float f = 0.0)
46 FloatBitRep(unsigned int i)
55 Float::Float(float value)
61 Float::Float(const Float& value)
72 Float::operator =(const Float& rhs)
82 Float::Compare(float f1, float f2)
103 Float::CompareTo(const Float& value) const
105 return(Float::Compare(this->value, value.value));
109 Float::Equals(const Object& obj) const
111 const Float* pOther = dynamic_cast< const Float* >(&obj);
118 if (Float::Compare(this->value, (*pOther).value) == 0)
129 Float::GetHashCode(void) const
131 float* pTemp = const_cast< float* >(&value);
132 int* pValue = reinterpret_cast< int* >(pTemp);
137 Float::GetHashCode(float val)
139 int* pValue = reinterpret_cast< int* >(&val);
144 Float::Parse(const String& s, float& ret)
146 double tmpRet = _LocalizedNumParser::ToFloat(s, "");
150 result r = GetLastResult();
151 SysLogException(NID_BASE, r, "[%s] Propagating.", GetErrorMessage(r));
160 Float::ToChar(void) const
162 return static_cast< char >(value);
166 Float::ToShort(void) const
168 return static_cast< short >(value);
172 Float::ToInt(void) const
174 return static_cast< int >(value);
178 Float::ToLong(void) const
180 return static_cast< long >(value);
184 Float::ToLongLong(void) const
186 return static_cast< long long >(value);
190 Float::ToFloat(void) const
196 Float::ToDouble(void) const
198 return static_cast< double >(value);
202 Float::ToString(void) const
204 return Float::ToString(value);
208 Float::ToString(float value)
210 return _LocalizedNumParser::ToString(value, "");
214 Float::ToBits(float value)
217 bitRep.value = value;
222 Float::ToFloatFromBits(int value)
230 Float::IsFinite(float value)
232 return isfinite(value);
236 Float::IsInfinity(void) const
238 return Float::IsInfinity(value);
242 Float::IsInfinity(float value)
244 return !Float::IsFinite(value);
248 Float::IsNaN(void) const
250 return Float::IsNaN(value);
254 Float::IsNaN(float value)
260 Float::GetMaxValue(void)
266 Float::GetMinValue(void)