int32

Translating Int32 into ushort and back again

I am attempting to devise a system for packing integer values greater than 65535 into a ushort. Let me explain. We have a system which generates Int32 values using an IDENTITY column from SQL Server and are limited by an in-production client API that overflows our Int32 IDs to ushorts. Fortunately the client only has about 20 or so in...

In C# is there any significant performance difference for using UInt32 vs Int32

I am porting an existing application to C# and want to improve performance wherever possible. Many existing loop counters and array references are defined as System.UInt32, instead of the Int32 I would have used. Is there any significant performance difference for using UInt32 vs Int32? ...

What is the int.MaxValue on a 64-bit PC?

Hi. System.Console.WriteLine(int.MaxValue); This line gives me the answer of 2147483647 as I have a 32-bit PC. Will the answer be same on a 64-bit PC? ...

WPF: System.Windows.Int32Rect ---> System.Windows.Int32Point?

You know how System.Drawing.Rectangle was replaced by System.Windows.Int32Rect? (As far as non-floating-point shapes are concerned ...) Is there a similar new object for an integer point or size? If not, I'll just use System.Drawing - but that kinda seems like a minor mix of two platforms that ought not to me mixed. Anyway, what do...

C# int, Int32 and enum's

If int is synonymous to Int32 why does enum MyEnum : Int32 { Value = 1 } ...not compile? Where as enum MyEnum : int { Value = 1 } will, even though hovering the cursor over the int word will display struct System.Int32? ...

int or uint or what

Consider this int i = 2147483647; var n = i + 3; i = n; Console.WriteLine(i); // prints -2147483646 (1) Console.WriteLine(n); // prints -2147483646 (2) Console.WriteLine(n.GetType()); // prints System.Int32 (3) I am confused with following (1) how coul...

What is the difference between Int32 and UInt32?

What is the difference between Int32 and UInt32? If they are the same with capacity range capabilities, the question is for what reason UInt32 was created? When should I use UInt32 instead of Int32? ...

Ascii Bytes Array To Int32 or Double

I'm re-writing alibrary with a mandate to make it totally allocation free. The goal is to have 0 collections after the app's startup phase is done. Previously, there were a lot of calls like this: Int32 foo = Int32.Parse(ASCIIEncoding.ASCII.GetString(bytes, start, length)); Which I believe is allocating a string. I couldn't find a ...

Determine if a decimal can be stored as int32

I am doing some custom serializing, and in order to save some space, i want to serialize the decimals as int, if possible value wise. Performance is a concern, since i am dealing with a high volume of data. The current method i use is: if ((value > Int32.MinValue) && (value < Int32.MaxValue) && ((valueAsInt = Decimal.ToInt32(value)) == ...

Min and Max value of integral type in C#

Whats the mathematical formulae to calculate the MIN and MAX value of an integral type using your calculator. I know you can use Integer.Max or Integer.Min etc or look it up on msdn however I want to know how to calculate it. ...

Apparently it's important to use Int32 instead of int when messing with DLLImport stuff?

In C#, when messing with that system DLLImport/(unmanaged?) code stuff, I read somewhere it's important to use Int32 exact type instead of int. Is this true? And can someone please elaborate on why it's important to do this? ...

Solve:Value was either too large or too small for an Int32.

I am passing query string and the url is as follows-> http://localhost:1086/Web/EditMobile.aspx?sno=2. But when i try to enter the url as follows,localhost:1086/Web/EditMobile.aspx?sno=2*3424324423432424* , i get the following error->Value was either too large or too small for an Int32. How do i handle this error. I must get an error re...

Convert.ToInt32(float) fails when trying to convert float to Int32

No exception is thrown, function just halts at this statement: int productQuantity = Convert.ToInt32("1.00"); and returns. What am I doing wrong to convert this float to Int32? Note: I am running in a BackgroundWorkerThread. ...