Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Storing really large numbers in C#

Posted on 2006-06-10
6
Medium Priority
?
1,218 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 800 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Assisted Solution

by:_Katka_
_Katka_ earned 400 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 400 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 400 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

610 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