src/Helpers.c
bool Char2FloatW(WCHAR* wnumber, float* fresult)
{
  if (!wnumber || !fresult) { return false; }

  int i = 0;
  for (; IsBlankCharW(wnumber[i]); ++i); // skip spaces

  // determine sign
  int const sign = (wnumber[i] == L'-') ? -1 : 1;
  if (wnumber[i] == L'-' || wnumber[i] == L'+') { ++i; }

  // must be digit now
  if (!IsDigitW(wnumber[i])) { return false; }

  // digits before decimal
  float val = 0.0f;
  while (IsDigitW(wnumber[i])) {
    val = (val * 10) + (wnumber[i] - L'0');
    ++i;
  }

  // skip decimal point (or comma) if present
  if ((wnumber[i] == L'.') || (wnumber[i] == L',')) { ++i; }

  //digits after decimal
  int place = 1;
  while (IsDigitW(wnumber[i])) {
    val = val * 10 + (wnumber[i] - L'0');
    place *= 10;
    ++i;
  }

  // the extended part for scientific notations
  float exponent = 1.0f;
  if (wnumber[i] == L'e' || wnumber[i] == L'E') {
    ++i;
    float fexp = 0.0f;
    if (Char2FloatW(&(wnumber[i]), &fexp)) {
      exponent = powf(10, fexp);
    }
  }

  *fresult = ((sign*val*exponent) / (place));
  return true;
}
//=============================================================================
//
//  Char2FloatW()
//  Locale indpendant simple character to tloat conversion
//
Char2FloatW()
Locale indpendant simple character to tloat conversion
Char2FloatW () Locale indpendant simple character to tloat conversion
bool Char2FloatW(WCHAR* wnumber, float* fresult)
{
  if (!wnumber || !fresult) { return false; }
  int i = 0;
  for (; IsBlankCharW(wnumber[i]); ++i); 
  int const sign = (wnumber[i] == L'-') ? -1 : 1;
  if (wnumber[i] == L'-' || wnumber[i] == L'+') { ++i; }
  if (!IsDigitW(wnumber[i])) { return false; }
  float val = 0.0f;
  while (IsDigitW(wnumber[i])) {
    val = (val * 10) + (wnumber[i] - L'0');
    ++i;
  }
  if ((wnumber[i] == L'.') || (wnumber[i] == L',')) { ++i; }
  int place = 1;
  while (IsDigitW(wnumber[i])) {
    val = val * 10 + (wnumber[i] - L'0');
    place *= 10;
    ++i;
  }
  float exponent = 1.0f;
  if (wnumber[i] == L'e' || wnumber[i] == L'E') {
    ++i;
    float fexp = 0.0f;
    if (Char2FloatW(&(wnumber[i]), &fexp)) {
      exponent = powf(10, fexp);
    }
  }
  *fresult = ((sign*val*exponent) / (place));
  return true;
}
bool Char2FloatW ( WCHAR * wnumber , float * fresult ) { if ( ! wnumber || ! fresult ) { return false ; } int i = 0 ; for ( ; IsBlankCharW ( wnumber [ i ] ) ; ++ i ) ; int const sign = ( wnumber [ i ] == L' ' ) ? -1 : 1 ; if ( wnumber [ i ] == L' ' || wnumber [ i ] == L' ' ) { ++ i ; } if ( ! IsDigitW ( wnumber [ i ] ) ) { return false ; } float val = 0.0f ; while ( IsDigitW ( wnumber [ i ] ) ) { val = ( val * 10 ) + ( wnumber [ i ] - L' ' ) ; ++ i ; } if ( ( wnumber [ i ] == L' ' ) || ( wnumber [ i ] == L' ' ) ) { ++ i ; } int place = 1 ; while ( IsDigitW ( wnumber [ i ] ) ) { val = val * 10 + ( wnumber [ i ] - L' ' ) ; place *= 10 ; ++ i ; } float exponent = 1.0f ; if ( wnumber [ i ] == L' ' || wnumber [ i ] == L' ' ) { ++ i ; float fexp = 0.0f ; if ( Char2FloatW ( & ( wnumber [ i ] ) , & fexp ) ) { exponent = powf ( 10 , fexp ) ; } } * fresult = ( ( sign * val * exponent ) / ( place ) ) ; return true ; }
Char2FloatW()
Locale indpendant simple character to tloat conversion
Char2FloatW () Locale indpendant simple character to tloat conversion
// skip spaces // determine sign // must be digit now // digits before decimal // skip decimal point (or comma) if present //digits after decimal // the extended part for scientific notations