1 #ifndef STLPLUS_PRINT_FLOAT 2 #define STLPLUS_PRINT_FLOAT 3 //////////////////////////////////////////////////////////////////////////////// 4 5 // Author: Andy Rushton 6 // Copyright: (c) Southampton University 1999-2004 7 // (c) Andy Rushton 2004 onwards 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 <iostream> 17 #include <stdexcept> 18 19 namespace stlplus 20 { 21 22 //////////////////////////////////////////////////////////////////////////////// 23 // convert a real type to string 24 //////////////////////////////////////////////////////////////////////////////// 25 26 // Only decimal radix is supported 27 28 // The way in which the number is displayed is defined in radix_types.hpp 29 // Using any other value for the display type causes std::invalid_argument to be thrown 30 31 // exceptions: std::invalid_argument 32 void print_float(std::ostream& device, float f, 33 real_display_t display = display_mixed, 34 unsigned width = 0, 35 unsigned precision = 6); 36 37 // exceptions: std::invalid_argument 38 void print_double(std::ostream& device, double f, 39 real_display_t display = display_mixed, 40 unsigned width = 0, 41 unsigned precision = 6); 42 43 //////////////////////////////////////////////////////////////////////////////// 44 45 } // end namespace stlplus 46 47 #endif 48