src/misc.h

changeset 542
46a33bdc0b36
parent 541
0e38beeb050a
child 571
ec534922f693
equal deleted inserted replaced
541:0e38beeb050a 542:46a33bdc0b36
35 // Returns whether a given string represents a floating point number. 35 // Returns whether a given string represents a floating point number.
36 bool numeric (const str& tok); 36 bool numeric (const str& tok);
37 37
38 // Simplifies the given fraction. 38 // Simplifies the given fraction.
39 void simplify (int& numer, int& denom); 39 void simplify (int& numer, int& denom);
40
41 void roundToDecimals (double& a, int decimals);
40 42
41 str join (initlist<StringFormatArg> vals, str delim = " "); 43 str join (initlist<StringFormatArg> vals, str delim = " ");
42 44
43 // Grid stuff 45 // Grid stuff
44 struct gridinfo 46 struct gridinfo
136 bool findRingsRecursor (double r0, double r1, Solution& currentSolution); 138 bool findRingsRecursor (double r0, double r1, Solution& currentSolution);
137 }; 139 };
138 140
139 extern RingFinder g_RingFinder; 141 extern RingFinder g_RingFinder;
140 142
141 // =============================================================================
142 template<class T> void dataswap (T& a, T& b)
143 { T c = a;
144 a = b;
145 b = c;
146 }
147
148 // ----------------------------------------------------------------------------- 143 // -----------------------------------------------------------------------------
149 // Plural expression 144 // Plural expression
150 template<class T> static inline const char* plural (T n) 145 template<class T> static inline const char* plural (T n)
151 { return (n != 1) ? "s" : ""; 146 { return (n != 1) ? "s" : "";
152 } 147 }

mercurial