ConvetToFloat api is modified that is unaffected by locale
authorkeonpyo.kong <keonpyo.kong@samsung.com>
Tue, 23 Apr 2013 08:47:33 +0000 (17:47 +0900)
committerkeonpyo.kong <keonpyo.kong@samsung.com>
Tue, 23 Apr 2013 08:58:54 +0000 (17:58 +0900)
Change-Id: I79c1043fa8a5a15110a4763121be552b89a2a489
Signed-off-by: keonpyo.kong <keonpyo.kong@samsung.com>
apply code review

Change-Id: Icb802a14a9c183ffeb1fa07a7218ea1a695be37e
Signed-off-by: keonpyo.kong <keonpyo.kong@samsung.com>
src/ui/inc/FUi_CoordinateSystemUtils.h

index f5af0bd..7c10f4e 100644 (file)
@@ -73,9 +73,47 @@ public:
                {
                        return 0.0f;
                }
-               std::unique_ptr<char[]> pFloatChar(Tizen::Base::_StringConverter::CopyToCharArrayN(floatString.GetPointer()));
-               float convertFolat = atof(pFloatChar.get());
-               return  convertFolat;
+               float integerPart = 0.0f;
+               float decimalPart = 0.0f;
+               float multiple = 1.0f;
+               float sign = 1.0f;
+               int index = 0;
+               bool isDecimal = false;
+
+               if (floatString[index] == L'-')
+               {
+                       sign = -1.0f;
+                       index ++;
+               }
+               else if (floatString[index] == L'+')
+               {
+                       sign = 1.0f;
+                       index ++;
+               }
+
+               while (index < floatString.GetLength())
+               {
+                       if (floatString[index] == L'.')
+                       {
+                               isDecimal = true;
+                       }
+                       else if (floatString[index] >= L'0' && floatString[index] <= L'9')
+                       {
+                               if (isDecimal)
+                               {
+                                       decimalPart = (decimalPart * 10.0f) + (floatString[index] - L'0');
+                                       multiple = 0.1f * multiple;
+                               }
+                               else
+                               {
+                                       integerPart = (integerPart * 10.0f) + (floatString[index] - L'0');
+                               }
+                       }
+                       index ++;
+               }
+               decimalPart = decimalPart * multiple;
+
+               return sign * (integerPart + decimalPart);
        }
 
        static float