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 FBaseDouble.cpp
19 * @brief This is the implementation file for Double class.
28 #include <FBaseDouble.h>
29 #include <FBaseResult.h>
30 #include <FBaseSysLog.h>
31 #include "FBase_LocalizedNumParser.h"
33 namespace Tizen { namespace Base
39 DoubleBitRep(double d = 0.0)
44 DoubleBitRep(long long l)
53 Double::Double(double value)
59 Double::Double(const Double& value)
70 Double::operator =(const Double& rhs)
80 Double::Compare(double d1, double d2)
99 Double::CompareTo(double value) const
101 return(Double::Compare(this->value, value));
105 Double::CompareTo(const Double& value) const
107 return(Double::Compare(this->value, value.value));
111 Double::Equals(const Object& obj) const
113 const Double* pOther = dynamic_cast< const Double* >(&obj);
120 if (Double::Compare(this->value, (*pOther).value) == 0)
131 Double::GetHashCode(void) const
133 double* pTemp = const_cast< double* >(&value);
134 int* pValueLow = reinterpret_cast< int* >(pTemp);
135 int* pValueHigh = pValueLow + 1;
136 return *pValueLow + *pValueHigh;
140 Double::GetHashCode(double val)
142 int* pValueLow = reinterpret_cast< int* >(&val);
143 int* pValueHigh = pValueLow + 1;
144 return *pValueLow + *pValueHigh;
148 Double::Parse(const String& s, double& ret)
150 double tmpRet = _LocalizedNumParser::ToDouble(s, "");
154 result r = GetLastResult();
155 SysLogException(NID_BASE, r, "[%s] Propagating.", GetErrorMessage(r));
164 Double::ToChar(void) const
166 return static_cast< char >(value);
170 Double::ToShort(void) const
172 return static_cast< short >(value);
176 Double::ToInt(void) const
178 return static_cast< int >(value);
182 Double::ToLong(void) const
184 return static_cast< long >(value);
188 Double::ToLongLong(void) const
190 return static_cast< long long >(value);
194 Double::ToFloat(void) const
196 return static_cast< float >(value);
200 Double::ToDouble(void) const
206 Double::ToString(void) const
208 return Double::ToString(value);
212 Double::ToString(double value)
214 return _LocalizedNumParser::ToString(value, "");
218 Double::ToBits(double value)
221 bitRep.value = value;
222 return (long long) bitRep.rep;
226 Double::ToDoubleFromBits(long long value)
234 Double::IsFinite(double d)
240 Double::IsInfinity(void) const
242 return Double::IsInfinity(value);
246 Double::IsInfinity(double value)
248 return !Double::IsFinite(value);
252 Double::IsNaN(void) const
254 return Double::IsNaN(value);
258 Double::IsNaN(double value)
264 Double::GetMaxValue(void)
270 Double::GetMinValue(void)