Solved

Storing really large numbers in C#

Posted on 2006-06-10
6
1,214 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
Technology Partners: 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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