source: icXML/icXML-devel/src/xercesc/util/XMLFloat.cpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 2.8 KB
Line 
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/*
19 * $Id: XMLFloat.cpp 803857 2009-08-13 12:16:44Z amassari $
20 */
21
22// ---------------------------------------------------------------------------
23//  Includes
24// ---------------------------------------------------------------------------
25#include <xercesc/util/XMLFloat.hpp>
26#include <math.h>
27
28XERCES_CPP_NAMESPACE_BEGIN
29
30// ---------------------------------------------------------------------------
31//  ctor/dtor
32// ---------------------------------------------------------------------------
33XMLFloat::XMLFloat(const XMLCh* const strValue,
34                   MemoryManager* const manager)
35:XMLAbstractDoubleFloat(manager)
36{
37    init(strValue);
38}
39
40XMLFloat::~XMLFloat()
41{
42}
43
44void XMLFloat::checkBoundary(char* const strValue)
45{
46    convert(strValue);
47
48    if (fDataConverted == false)
49    {
50        /**
51         *  float related checking
52         */
53
54        // 3.2.4 The basic value space of float consists of the values m × 2^e, where
55        //    m is an integer whose absolute value is less than 2^24,
56        //    and e is an integer between -149 and 104, inclusive
57        static const double fltMin = pow(2.0,-149);
58        static const double fltMax = pow(2.0,24) * pow(2.0,104);
59        if (fValue < (-1) * fltMax)
60        {
61            fType = NegINF;
62            fDataConverted = true;
63            fDataOverflowed = true;
64        }
65        else if (fValue > (-1)*fltMin && fValue < 0)
66        {
67            fDataConverted = true;
68            fValue = 0;
69        }
70        else if (fValue > 0 && fValue < fltMin )
71        {
72            fDataConverted = true;
73            fValue = 0;
74        }
75        else if  (fValue > fltMax)
76        {
77            fType = PosINF;
78            fDataConverted = true;
79            fDataOverflowed = true;
80        }
81    }
82}
83
84/***
85 * Support for Serialization/De-serialization
86 ***/
87
88IMPL_XSERIALIZABLE_TOCREATE(XMLFloat)
89
90XMLFloat::XMLFloat(MemoryManager* const manager)
91:XMLAbstractDoubleFloat(manager)
92{
93}
94
95void XMLFloat::serialize(XSerializeEngine& serEng)
96{
97    XMLAbstractDoubleFloat::serialize(serEng);
98}
99
100XERCES_CPP_NAMESPACE_END
Note: See TracBrowser for help on using the repository browser.