lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [4/7] lucenenet git commit: More work into Number helper class
Date Fri, 14 Nov 2014 11:06:52 GMT
More work into Number helper class


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/ec71eac8
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/ec71eac8
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/ec71eac8

Branch: refs/heads/master
Commit: ec71eac8c20cb87302913ef38d69f9f5934d2edc
Parents: 4f1399f
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Fri Nov 14 12:56:29 2014 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Fri Nov 14 12:57:05 2014 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Core/Support/Number.cs | 32 ++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ec71eac8/src/Lucene.Net.Core/Support/Number.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Number.cs b/src/Lucene.Net.Core/Support/Number.cs
index 13bf69e..e3f0744 100644
--- a/src/Lucene.Net.Core/Support/Number.cs
+++ b/src/Lucene.Net.Core/Support/Number.cs
@@ -27,7 +27,7 @@ namespace Lucene.Net.Support
     /// <summary>
     /// A simple class for number conversions.
     /// </summary>
-    public class Number
+    public static class Number
     {
         /// <summary>
         /// Min radix value.
@@ -42,16 +42,16 @@ namespace Lucene.Net.Support
         /*public const int CHAR_MIN_CODE_POINT =
         public const int CHAR_MAX_CODE_POINT = */
 
-        private const System.String digits = "0123456789abcdefghijklmnopqrstuvwxyz";
+        private const string digits = "0123456789abcdefghijklmnopqrstuvwxyz";
 
         /// <summary>
         /// Converts a number to System.String.
         /// </summary>
         /// <param name="number"></param>
         /// <returns></returns>
-        public static System.String ToString(long number)
+        public static string ToString(long number)
         {
-            System.Text.StringBuilder s = new System.Text.StringBuilder();
+            var s = new System.Text.StringBuilder();
 
             if (number == 0)
             {
@@ -99,12 +99,12 @@ namespace Lucene.Net.Support
         /// <param name="i">A number to be converted.</param>
         /// <param name="radix">A radix.</param>
         /// <returns>A System.String representation of the number in the specified
redix.</returns>
-        public static System.String ToString(long i, int radix)
+        public static String ToString(long i, int radix)
         {
             if (radix < MIN_RADIX || radix > MAX_RADIX)
                 radix = 10;
 
-            char[] buf = new char[65];
+            var buf = new char[65];
             int charPos = 64;
             bool negative = (i < 0);
 
@@ -482,5 +482,25 @@ namespace Lucene.Net.Support
             long x = BitConverter.DoubleToInt64Bits(d);
             return BitConverter.Int64BitsToDouble(FlipEndian(x));
         }
+
+        public static bool IsNumber(this object value)
+        {
+            return value is sbyte
+                   || value is byte
+                   || value is short
+                   || value is ushort
+                   || value is int
+                   || value is uint
+                   || value is long
+                   || value is ulong
+                   || value is float
+                   || value is double
+                   || value is decimal;
+        }
+
+        public static long DoubleToRawLongBits(double d)
+        {
+            return BitConverter.DoubleToInt64Bits(d);
+        }
     }
 }
\ No newline at end of file


Mime
View raw message