You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2013/05/06 02:45:19 UTC

git commit: [flex-sdk] [refs/heads/develop] - FLEX-18951 Fixed to support scientific notation (as both numbers and strings)

Updated Branches:
  refs/heads/develop 068c787f1 -> 7071779f6


FLEX-18951 Fixed to support scientific notation (as both numbers and strings)


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/7071779f
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/7071779f
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/7071779f

Branch: refs/heads/develop
Commit: 7071779f6f5dc28e24a86aea75eba54d3d1463d7
Parents: 068c787
Author: Justin Mclean <jm...@apache.org>
Authored: Mon May 6 10:44:04 2013 +1000
Committer: Justin Mclean <jm...@apache.org>
Committed: Mon May 6 10:44:04 2013 +1000

----------------------------------------------------------------------
 .../framework/src/mx/formatters/NumberBase.as      |   18 ++++++++++++++-
 .../framework/src/mx/formatters/NumberFormatter.as |    5 ++-
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/7071779f/frameworks/projects/framework/src/mx/formatters/NumberBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/formatters/NumberBase.as b/frameworks/projects/framework/src/mx/formatters/NumberBase.as
index 91568b9..95796e9 100644
--- a/frameworks/projects/framework/src/mx/formatters/NumberBase.as
+++ b/frameworks/projects/framework/src/mx/formatters/NumberBase.as
@@ -480,7 +480,7 @@ public class NumberBase
 	 *  @productversion Flex 3
 	 */
 	public function parseNumberString(str:String):String
-	{
+	{	
 		// Check the decimal and thousands formatting for validity.
 		var splitDec:Array = str.split(decimalSeparatorFrom);
 		if (splitDec.length > 2)
@@ -492,6 +492,7 @@ public class NumberBase
 		var letter:String;
 		var num:String;
 		var isNegative:Boolean = false;
+		var hasExponent:Boolean = false
 
 		while (count < len)
 		{
@@ -513,11 +514,26 @@ public class NumberBase
 					letter = str.charAt(count);
 					count++;
 					if ("0" <= letter && letter <= "9")
+					{
 						num += letter;
+					}
 					else if (letter == decimalSeparatorFrom)
+					{
 						num += ".";
+					}
+					else if (letter == "e" || letter == "E")
+					{
+						num += letter;
+						hasExponent = true;
+					}
+					else if (hasExponent && (letter == "-" || letter == "+"))
+					{
+						num += letter;
+					}
 					else if (letter != thousandsSeparatorFrom || count >= len)
+					{
 						break;
+					}
 				}
 			}
 		}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/7071779f/frameworks/projects/framework/src/mx/formatters/NumberFormatter.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/formatters/NumberFormatter.as b/frameworks/projects/framework/src/mx/formatters/NumberFormatter.as
index 04ff7be..fbe9aff 100644
--- a/frameworks/projects/framework/src/mx/formatters/NumberFormatter.as
+++ b/frameworks/projects/framework/src/mx/formatters/NumberFormatter.as
@@ -594,7 +594,7 @@ public class NumberFormatter extends Formatter
 
         var numStr:String = value.toString();
         
-        numStr.toLowerCase();
+		numStr = numStr.toLowerCase();
         var e:int = numStr.indexOf("e");
         if (e != -1)  //deal with exponents
             numStr = dataFormatter.expandExponents(numStr);
@@ -626,7 +626,8 @@ public class NumberFormatter extends Formatter
         else if (Math.abs(numValue) > 0)
         {
             // Check if the string is in scientific notation
-            if (numStr.indexOf("e") != -1)
+			numStr = numStr.toLowerCase();
+			if (numStr.indexOf("e") != -1)
             {
                 var temp:Number = Math.abs(numValue) + 1;
                 numStr = temp.toString();