| 34 | } |
| 35 | |
| 36 | static bool StrToFloat( const char* str, float* f ) |
| 37 | { |
| 38 | float sign = 1.0f; |
| 39 | if( str[0] == '-' ) |
| 40 | { |
| 41 | sign = -1.0f; |
| 42 | str++; |
| 43 | } |
| 44 | |
| 45 | float v = 0; |
| 46 | while( *str != 0 ) |
| 47 | { |
| 48 | if( str[0] == ',' || str[0] == '.' ) |
| 49 | { |
| 50 | str++; |
| 51 | break; |
| 52 | } |
| 53 | if( str[0] < '0' || str[0] > '9' ) |
| 54 | return false; |
| 55 | v*= 10.0f; |
| 56 | v+= float(str[0] - '0'); |
| 57 | str++; |
| 58 | } |
| 59 | float m = 0.1f; |
| 60 | while( *str != 0 ) |
| 61 | { |
| 62 | if( str[0] < '0' || str[0] > '9' ) |
| 63 | return false; |
| 64 | |
| 65 | v+= float(str[0] - '0') * m; |
| 66 | m*= 0.1f; |
| 67 | str++; |
| 68 | } |
| 69 | |
| 70 | *f= v * sign; |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | std::string FloatToStr( const float f ) |
| 75 | { |
no outgoing calls
no test coverage detected