?
Solved

Storing really large numbers in C#

Posted on 2006-06-10
6
Medium Priority
?
1,217 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

800 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