/[OhmsLawCalc]/trunk/libOhmsLawCalc/OhmsLawTypes.cs
ViewVC logotype

Diff of /trunk/libOhmsLawCalc/OhmsLawTypes.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/libOhmsLawCalc/OhmsLawTypes.cs	2014/01/29 07:57:25	22
+++ trunk/libOhmsLawCalc/OhmsLawTypes.cs	2014/01/29 08:07:43	23
@@ -84,6 +84,22 @@
             return CreateInstance(type, values.ToList());
         }
 
+        public static OhmsLawValue AutoConvertResult(OhmsLawValue result)
+        {
+            int v = (int)result.Value;
+            while (v == 0)
+            {
+                if (result.UnitType == OhmsLawUnitType.None)
+                {
+                    break;
+                }
+                result = ConvertResult(result, (OhmsLawUnitType)((int)result.UnitType - 1));
+                v = (int)result.Value;
+            }
+
+            return result;
+        }
+
         public static OhmsLawValue ConvertResult(OhmsLawValue result, OhmsLawUnitType unit)
         {
             OhmsLawValue olv = OhmsLawValue.Empty;

 

  ViewVC Help
Powered by ViewVC 1.1.22