Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET1.0 .NET1.1 .NET2.0 .NET3.0 , +
Hi Experts,
 
I have face many time a Question. why the Integer size is 2,147,483,647 .
What numeric datatype we are using if the length of data is more then 80 characters.
 
If you have any suggestion or Solution for that then pls share it.
 

Thanks
Posted 25-Feb-13 7:50am
Comments
richcb at 25-Feb-13 12:52pm
   
Use a long datatype. However, I am not sure even a long can handle 80 characters.
eg_Anubhava at 25-Feb-13 12:55pm
   
The Question is Why?? Just imagine the 9999999999999999999999999999999999999999999999999999999999 is an integer value . then what datatype will be use.
joshrduncan2012 at 25-Feb-13 12:59pm
   
Is there something that you didn't understand about rich's answer. Can you elaborate more as to the context behind your question if you don't understand rich's answer? If a long can't be used, you may have to add a custom class for a BigInt.
eg_Anubhava at 25-Feb-13 13:08pm
   
thanks for the support. Can u pls expain me how can i create the class there i can store this value.
joshrduncan2012 at 25-Feb-13 13:11pm
   
I strongly suggest googling for source code for the BigInteger class in C#. There are several websites available, and there is also one description here on CodeProject available.
BC @ CV at 25-Feb-13 13:01pm
   
If you need whole numbers you could use this.
If you need really large floating points you could use this.
eg_Anubhava at 25-Feb-13 13:08pm
   
thanks for the support. Can u pls expain me how can i create the class there i can store this value.
BC @ CV at 25-Feb-13 13:47pm
   
To load BigInteger with a number larger than a long or double you will need to use a byte array. If you use the number class on the blog, you can just use a string like so:
 
Number myBigFatGreekNumber = new Number("3.141592653589793238462643383279502884197169399375105820974944592307816406");
richcb at 25-Feb-13 13:02pm
   
It is that size because that is the max value a 32-bit integer can hold. I told you, a "Long" is one of the largest numerical datatype, but I don't think it can handle an 80 character number.
Sergey Alexandrovich Kryukov at 25-Feb-13 14:01pm
   
Please see my answer.
—SA
ThePhantomUpvoter at 25-Feb-13 13:01pm
   
Because that is the largest value you have have in a 32 bit integer (2 ^ 32 - 1). If you want something larger use the BigInteger class.
eg_Anubhava at 25-Feb-13 13:08pm
   
thanks for the support. Can u pls expain me how can i create the class there i can store this value.
ryanb31 at 25-Feb-13 13:18pm
   
Give an example of what you need.
Sergey Alexandrovich Kryukov at 26-Feb-13 19:55pm
   
Please stop posting non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership.
Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Add a reference to the System.Numerics assembly, then add using System.Numerics; to the c# source and then declare your numbers using the type BigInteger instead of int.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

No, the sizes of integers types are 1, 2, 4, 8, 16, 32, 64 or maybe 128 bytes…
 
On the presentation of integer values, please see: http://en.wikipedia.org/wiki/2%27s_complement[^].
 
This is by far the most usual representation. This article should explain everything to you.
 
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 535
1 Kornfeld Eliyahu Peter 407
2 Maciej Los 369
3 DamithSL 221
4 OriginalGriff 218
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,917


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100