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.
29 #include <FBaseDouble.h>
30 #include <FBaseResult.h>
31 #include <FBaseSysLog.h>
32 #include "FBase_LocalizedNumParser.h"
35 namespace Tizen { namespace Base
41 DoubleBitRep(double d = 0.0)
46 DoubleBitRep(long long l)
55 Double::Double(double value)
61 Double::Double(const Double& value)
72 Double::operator =(const Double& rhs)
82 Double::Compare(double d1, double d2)
101 Double::CompareTo(double value) const
103 return(Double::Compare(this->value, value));
107 Double::CompareTo(const Double& value) const
109 return(Double::Compare(this->value, value.value));
113 Double::Equals(const Object& obj) const
115 const Double* pOther = dynamic_cast< const Double* >(&obj);
122 if (Double::Compare(this->value, (*pOther).value) == 0)
133 Double::GetHashCode(void) const
135 double* pTemp = const_cast< double* >(&value);
136 int* pValueLow = reinterpret_cast< int* >(pTemp);
137 int* pValueHigh = pValueLow + 1;
138 return *pValueLow + *pValueHigh;
142 Double::GetHashCode(double val)
144 int* pValueLow = reinterpret_cast< int* >(&val);
145 int* pValueHigh = pValueLow + 1;
146 return *pValueLow + *pValueHigh;
150 Double::Parse(const String& s, double& ret)
152 double tmpRet = _LocalizedNumParser::ToDouble(s, "");
156 result r = GetLastResult();
157 SysLogException(NID_BASE, r, "[%s] Propagating.", GetErrorMessage(r));
166 Double::ToChar(void) const
168 return static_cast< char >(value);
172 Double::ToShort(void) const
174 return static_cast< short >(value);
178 Double::ToInt(void) const
180 return static_cast< int >(value);
184 Double::ToLong(void) const
186 return static_cast< long >(value);
190 Double::ToLongLong(void) const
192 return static_cast< long long >(value);
196 Double::ToFloat(void) const
198 return static_cast< float >(value);
202 Double::ToDouble(void) const
208 Double::ToString(void) const
210 return Double::ToString(value);
214 Double::ToString(double value)
216 return _LocalizedNumParser::ToString(value, "");
220 Double::ToBits(double value)
223 bitRep.value = value;
224 return (long long) bitRep.rep;
228 Double::ToDoubleFromBits(long long value)
236 Double::IsFinite(double d)
242 Double::IsInfinity(void) const
244 return Double::IsInfinity(value);
248 Double::IsInfinity(double value)
250 return !Double::IsFinite(value);
254 Double::IsNaN(void) const
256 return Double::IsNaN(value);
260 Double::IsNaN(double value)
266 Double::GetMaxValue(void)
272 Double::GetMinValue(void)