Click here to Skip to main content
12,078,742 members (44,056 online)
Rate this:
 
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 25-Feb-13 12:52pm
   
Use a long datatype. However, I am not sure even a long can handle 80 characters.
eg_Anubhava 25-Feb-13 12:55pm
   
The Question is Why?? Just imagine the 9999999999999999999999999999999999999999999999999999999999 is an integer value . then what datatype will be use.
joshrduncan2012 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 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 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 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 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 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 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 25-Feb-13 14:01pm
   
Please see my answer.
—SA
ThePhantomUpvoter 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 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 25-Feb-13 13:18pm
   
Give an example of what you need.
Sergey Alexandrovich Kryukov 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160212.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2016
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