1 /////////////////////////////////////////////////////////////////////////
2 // ftos.h
3 //
4 // Copyright (c) 1996 Bryce W. Harrington - bryce@neptune.net
5 //
6 //-----------------------------------------------------------------------
7 // License: This code may be used by anyone for any purpose
8 // so long as the copyright notices and this license
9 // statement remains attached.
10 //-----------------------------------------------------------------------
11 // Description of file contents
12 // 1993 - Bryce Harrington
13 // Created initial ftoa routine
14 //
15 // October 1996 - Bryce Harrington
16 // Created itos from code taken from Kernighan & Ritchie
17 // _The C Programming Language_ 2nd edition
18 //
19 // November 1996 - Bryce Harrington
20 // Created new ftoa and ftos
21 //
22 // July 1999 - Bryce Harrington
23 // Ported to Linux for use in WorldForge
24 //
25 // January 2000 - Karsten Laux klaux@rhrk.uni-kl.de
26 // added ultos - convering ulong to string
27 //
28 /////////////////////////////////////////////////////////////////////////
29 #ifndef ftos_h
30 #define ftos_h
32 #include <string>
34 // ftos routine
35 const int FORCE_X10 = (1 << 0);
36 const int FORCE_DECIMAL = (1 << 1);
37 const int FORCE_EXP_ZERO = (1 << 2);
38 const int FORCE_HUNDRED_EXP_ZERO = (1 << 3);
39 const int FORCE_EXP_PLUS = (1 << 4);
40 const int FORCE_EXP = (1 << 5);
41 const int FORCE_PLUS = (1 << 6);
43 ///
44 std::string ftos(double val, char mode='g', int sigfig=-1, int precision=-1, int options=0);
45 ///
46 std::string itos(int n);
47 ///
48 std::string ultos(unsigned long n);
49 ///
50 double rround(double x); // use rounding rule -> x to nearest int.
51 ///
52 double rround(double x, int k); // round to the kth place
54 #endif // ftos_h