|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72954 - in trunk: boost libs/conversion libs/conversion/test
From: antoshkka_at_[hidden]
Date: 2011-07-07 07:31:25
Author: apolukhin
Date: 2011-07-07 07:31:25 EDT (Thu, 07 Jul 2011)
New Revision: 72954
URL: http://svn.boost.org/trac/boost/changeset/72954
Log:
Fixes #5675. Adds tests on #5675.
Updates #5660. Updates performance section of documentation
Text files modified:
trunk/boost/lexical_cast.hpp | 14 ++++++++------
trunk/libs/conversion/lexical_cast.htm | 2 +-
trunk/libs/conversion/test/lexical_cast_float_types_test.cpp | 8 +++++++-
3 files changed, 16 insertions(+), 8 deletions(-)
Modified: trunk/boost/lexical_cast.hpp
==============================================================================
--- trunk/boost/lexical_cast.hpp (original)
+++ trunk/boost/lexical_cast.hpp 2011-07-07 07:31:25 EDT (Thu, 07 Jul 2011)
@@ -798,12 +798,8 @@
if (begin == end) return false;
}
- if ( *begin < czero || *begin >= czero + 10 ) {
- return false;
- }
-
-
bool found_decimal = false;
+ bool found_number_before_exp = false;
int pow_of_10 = 0;
mantissa_type mantissa=0;
bool is_mantissa_full = false;
@@ -830,6 +826,8 @@
-- pow_of_10;
mantissa = tmp_mantissa;
mantissa += *begin - zero;
+
+ found_number_before_exp = true;
} else {
if (*begin >= czero && *begin < czero + 10) {
@@ -851,6 +849,7 @@
++ pow_of_10;
}
+ found_number_before_exp = true;
++ length_since_last_delim;
} else if ( *begin == decimal_point || *begin == lowercase_e || *begin == capital_e) {
#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
@@ -874,7 +873,10 @@
++ begin;
found_decimal = true;
continue;
- }else break;
+ }else {
+ if (!found_number_before_exp) return false;
+ break;
+ }
}
#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
else if (grouping_size && *begin == thousands_sep){
Modified: trunk/libs/conversion/lexical_cast.htm
==============================================================================
--- trunk/libs/conversion/lexical_cast.htm (original)
+++ trunk/libs/conversion/lexical_cast.htm 2011-07-07 07:31:25 EDT (Thu, 07 Jul 2011)
@@ -331,7 +331,7 @@
<tr><td>string->int</td><td bgcolor="#00C000">7</td><td>115</td><td>23</td><td>18</td></tr>
<tr><td>string->unsigned int</td><td bgcolor="#00C000">7</td><td>117</td><td>22</td><td>17</td></tr>
<tr><td>string->bool</td><td bgcolor="#00C000"><1</td><td>104</td><td>19</td><td>10</td></tr>
- <tr><td>string->float</td><td>85</td><td>172</td><td>60</td><td bgcolor="#00C000">33</td></tr>
+ <tr><td>string->float</td><td bgcolor="#00C000">13</td><td>172</td><td>60</td><td>33</td></tr>
<tr><td>char->string</td><td bgcolor="#00C000">7</td><td>105</td><td>16</td><td>12</td></tr>
<tr><td>int->string</td><td bgcolor="#00C000">15</td><td>131</td><td>21</td><td>17</td></tr>
<tr><td>unsigned int->string</td><td bgcolor="#00C000">14</td><td>125</td><td>21</td><td>17</td></tr>
Modified: trunk/libs/conversion/test/lexical_cast_float_types_test.cpp
==============================================================================
--- trunk/libs/conversion/test/lexical_cast_float_types_test.cpp (original)
+++ trunk/libs/conversion/test/lexical_cast_float_types_test.cpp 2011-07-07 07:31:25 EDT (Thu, 07 Jul 2011)
@@ -194,7 +194,9 @@
CHECK_CLOSE_ABS_DIFF(0.0E-1, test_t);
CHECK_CLOSE_ABS_DIFF(-1.0E-1, test_t);
-
+ CHECK_CLOSE_ABS_DIFF(.0E-1, test_t);
+ CHECK_CLOSE_ABS_DIFF(.0E-1, test_t);
+ CHECK_CLOSE_ABS_DIFF(-.0E-1, test_t);
CHECK_CLOSE_ABS_DIFF(10.0, test_t);
CHECK_CLOSE_ABS_DIFF(00.0, test_t);
@@ -235,6 +237,10 @@
CHECK_CLOSE_ABS_DIFF(-10101.0E-011, test_t);
CHECK_CLOSE_ABS_DIFF(-10101093, test_t);
CHECK_CLOSE_ABS_DIFF(10101093, test_t);
+
+ CHECK_CLOSE_ABS_DIFF(-.34, test_t);
+ CHECK_CLOSE_ABS_DIFF(.34, test_t);
+ CHECK_CLOSE_ABS_DIFF(.34e10, test_t);
// BOOST_CHECK(lexical_cast<test_t>("-inf") == -std::numeric_limits<test_t>::infinity() );
// BOOST_CHECK(lexical_cast<test_t>("-INF") == -std::numeric_limits<test_t>::infinity() );
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk