Changeset 14219 for trunk/FACT++/src/tools.cc
- Timestamp:
- 06/22/12 22:54:26 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/tools.cc
r14054 r14219 11 11 12 12 #include <stdarg.h> 13 #include <iomanip> 14 #include <sstream> 13 15 14 16 #include <boost/tokenizer.hpp> … … 143 145 } 144 146 147 string Tools::Scientific(uint64_t val) 148 { 149 ostringstream rc; 150 rc << setprecision(1) << fixed; 151 152 if (val<1000) 153 { 154 rc << val << " "; 155 return rc.str(); 156 } 157 158 if (val<3000) 159 { 160 rc << val/1000. << " k"; 161 return rc.str(); 162 } 163 164 if (val<1000000) 165 { 166 rc << val/1000 << " k"; 167 return rc.str(); 168 } 169 170 if (val<3000000) 171 { 172 rc << val/1000000. << " M"; 173 return rc.str(); 174 } 175 176 if (val<1000000000) 177 { 178 rc << val/1000000 << " M"; 179 return rc.str(); 180 } 181 182 if (val<3000000000) 183 { 184 rc << val/1000000000. << " G"; 185 return rc.str(); 186 } 187 188 if (val<1000000000000) 189 { 190 rc << val/1000000000 << " G"; 191 return rc.str(); 192 } 193 194 if (val<3000000000000) 195 { 196 rc << val/1000000000000. << " T"; 197 return rc.str(); 198 } 199 200 if (val<1000000000000000) 201 { 202 rc << val/1000000000000 << " T"; 203 return rc.str(); 204 } 205 206 if (val<3000000000000000) 207 { 208 rc << val/1000000000000000. << " P"; 209 return rc.str(); 210 } 211 212 rc << val/1000000000000000. << " P"; 213 return rc.str(); 214 } 215 145 216 // -------------------------------------------------------------------------- 146 217 //
Note:
See TracChangeset
for help on using the changeset viewer.