-2

The maximum value for Int32 is 2,147,483,647. I am comparing integer values that are greater than the maximum value and it is not working. Maximum number can be 9999999999.99.

Which data type should I use to compare integer values larger than Int32.MaxValue?

George Stocker
  • 57,289
  • 29
  • 176
  • 237
Sunny
  • 4,765
  • 5
  • 37
  • 72
  • 3
    Have you tried the `long` data type? – George Stocker Apr 10 '14 at 15:28
  • 4
    Just for reference so the asker knows: `long` and `int64` are the same thing, just different names. – Brian Snow Apr 10 '14 at 15:30
  • possible duplicate of [How do you deal with numbers larger than UInt64 (C#)](http://stackoverflow.com/questions/1298787/how-do-you-deal-with-numbers-larger-than-uint64-c) – Sayse Apr 10 '14 at 15:31
  • @Sayse, not really a duplicate of the linked question. – Habib Apr 10 '14 at 15:33
  • 2
    The OP should learn how to google things, or at least to read C# types docs – MikeSW Apr 10 '14 at 15:34
  • 1
    9999999999.99 is not integral – Joel Coehoorn Apr 10 '14 at 15:38
  • I didn't expect downvotes for this. – Sunny Apr 10 '14 at 15:38
  • @Sunny well , this already have many answers so sorry about that. SOmeone may see this a duplicate of some question. – Poomrokc The 3years Apr 10 '14 at 15:39
  • Isn't duplicate and downvote different. – Sunny Apr 10 '14 at 15:44
  • 1
    @Sunny If you don't want to have your question be downvoted then take the time to do some basic research before asking your question. Do some web searches related to your question, look around, do some research. When you spend literally zero time trying to solve a problem that is *extremely* easy to discover the solution for, you should expect downvotes. – Servy Apr 10 '14 at 15:46
  • @Sunny The 'hover' for the downvote arrow says, "This question does not show any research effort..." That definitely applies to this question. – George Stocker Apr 10 '14 at 18:03

3 Answers3

4

Use a long instead of an integer. That can handle numbers up into the 9 Quintillion range.

Also, given that your max value includes a decimal point, are you sure you don't want a decimal instead?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
2

Long(INT64) is for integers that have the maxvalue of 9,223,372,036,854,775,807

Long is stored in 64bit and 64 bit = 8 bytes. 1 byte can be written in a hexadecimal number with the max value of FF(F=16) per byte. So 8 bytes have the maxvalue as 0x7FFFFFFFFFFFFFFF in hexadecimal or 9,223,372,036,854,775,807 in decimal.

Also, there is short(int16) which stores in 2 byte and have the maxvalue of 32767

Hope you understand

Ref:int16:http://msdn.microsoft.com/en-us/library/system.int16.maxvalue(v=vs.110).aspx Ref:Int64:http://msdn.microsoft.com/en-us/library/vstudio/system.int64.maxvalue

Poomrokc The 3years
  • 1,099
  • 2
  • 10
  • 23
2

If your values can have up to 2 decimal points, you should use the Decimal type.

Tony Vitabile
  • 8,298
  • 15
  • 67
  • 123