common.cpp
Go to the documentation of this file.
00001 #include <megatree/common.h>
00002 
00003 namespace megatree {
00004 
00005 int parseNumberSuffixed(const char* s)
00006 {
00007   char *end;
00008   float f = strtod(s, &end);
00009   switch (end[0]) {
00010   case '\0':
00011     break;
00012   case 'k':
00013   case 'K':
00014     f *= 1e3f;
00015   break;
00016   case 'm':
00017   case 'M':
00018     f *= 1e6f;
00019   break;
00020   case 'g':
00021   case 'G':
00022     f *= 1e9f;
00023   break;
00024   default:
00025     fprintf(stderr, "Weird suffix (%s) on number: %s\n", end, s);
00026     break;
00027   }
00028 
00029   return (int)f;
00030 }
00031 
00032 }


megatree_core
Author(s): Stuart Glaser
autogenerated on Thu Nov 28 2013 11:30:23