]> Dogcows Code - chaz/yoink/blob - src/stlplus/strings/string_float.hpp
build system enhancements
[chaz/yoink] / src / stlplus / strings / string_float.hpp
1 #ifndef STLPLUS_STRING_FLOAT
2 #define STLPLUS_STRING_FLOAT
3 ////////////////////////////////////////////////////////////////////////////////
4
5 // Author: Andy Rushton
6 // Copyright: (c) Southampton University 1999-2004
7 // (c) Andy Rushton 2004-2009
8 // License: BSD License, see ../docs/license.html
9
10 // Convert a float/double to/from string
11
12 ////////////////////////////////////////////////////////////////////////////////
13 #include "strings_fixes.hpp"
14 #include "format_types.hpp"
15 #include <string>
16 #include <stdexcept>
17
18 namespace stlplus
19 {
20
21 ////////////////////////////////////////////////////////////////////////////////
22 // convert a real type to string
23 ////////////////////////////////////////////////////////////////////////////////
24
25 // Only decimal radix is supported
26
27 // The way in which the number is displayed is defined in radix_types.hpp
28 // Using any other value for the display type causes std::invalid_argument to be thrown
29
30 std::string float_to_string(float f,
31 real_display_t display = display_mixed,
32 unsigned width = 0,
33 unsigned precision = 6)
34 throw(std::invalid_argument);
35
36 std::string double_to_string(double f,
37 real_display_t display = display_mixed,
38 unsigned width = 0,
39 unsigned precision = 6)
40 throw(std::invalid_argument);
41
42 ////////////////////////////////////////////////////////////////////////////////
43 // Convert a string to a floating-point type
44
45 float string_to_float(const std::string& value)
46 throw(std::invalid_argument);
47
48 double string_to_double(const std::string& value)
49 throw(std::invalid_argument);
50
51 ////////////////////////////////////////////////////////////////////////////////
52
53 } // end namespace stlplus
54
55 #endif
This page took 0.032593 seconds and 4 git commands to generate.