Solved

Storing really large numbers in C#

Posted on 2006-06-10
6
1,215 Views
Last Modified: 2008-01-09
I have this:

 this.button1.Text = DateTime.Now.Ticks.ToString();


which gives me numbers like:


632855413326400752


what I want to do is store this number, not in a text box, but in a variable whose type is large enough to store this value.


I don't know of any variable large enough to store this number.


What options do I have?
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 16878068
Also, i need an online reference for the C# data types and how large of values can each one hold:  int, long, double, word, etc.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 16878090
Huh, I guess a "long" does hold a number that big.
0
 
LVL 5

Accepted Solution

by:
aaronfeng earned 200 total points
ID: 16878112
Here is the link you want, just click on the data type you would to see more info about it:  http://msdn2.microsoft.com/en-us/ya5y69ds.aspx

You can use long to store that number, or use ulong to be safe because that number can't be negative anyways.

Cheers,

Aaron
http://geekswithblogs.net/afeng
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Assisted Solution

by:_Katka_
_Katka_ earned 100 total points
ID: 16881447
Hi, just to make it clear:

long actualNow = DateTime.Now.Ticks;

because DateTime.Now.Ticks property is defined:

public long Ticks {get; }

regards,
Kate
0
 
LVL 5

Assisted Solution

by:t_itanium
t_itanium earned 100 total points
ID: 16884177
you can store it in a string variable....


or also you can do that in byte.
cheers
0
 
LVL 25

Assisted Solution

by:dstanley9
dstanley9 earned 100 total points
ID: 16885438
You could also use the BigInteger datatype from J#:

(from http://msdn.microsoft.com/msdnmag/issues/05/12/NETMatters/)

BigInteger i = new BigInteger(ulong.MaxValue.ToString());
BigInteger iSquared = i.multiply(i);
Console.WriteLine("i:\t" + i);
Console.WriteLine("i^2:\t" + iSquared);



i:      18446744073709551615
i^2:    340282366920938463426481119284349108225
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question