Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to input this type of numbers and save in any variable and print it..
Number Like this...
2318678973167632186632156464312357431213574631247864132153346979
Posted
Comments
Zoltán Zörgő 26-Aug-13 14:22pm    
You better post here the whole text of your assignment, since it is hard to believe, that a teacher could write such nonsense... it is more likely that you have not understood it.

Use a BigInteger[^] (available in .NET 4.0 and higher).
First, add a reference to System.Numerics.dll.
Then, add this at the top of your code file:
C#
using System.Numerics;

Now, use the BigInteger.Parse[^] method to parse your number:
C#
BigInteger b = BigInteger.Parse("2318678973167632186632156464312357431213574631247864132153346979");
// now, you can do some other operations with it such as multiplying, dividing ...
Console.WriteLine(b.ToString()); // prints the large number on the console

Hope this helps.
 
Share this answer
 
v2
Comments
Arsalaan Ahmed 26-Aug-13 13:42pm    
how to do this without using any dll..?
Thomas Daniels 26-Aug-13 13:47pm    
You can't, but System.Numerics.dll is included in the .NET Framework, so you don't have to install anything.
Arsalaan Ahmed 26-Aug-13 13:49pm    
this is my assignment.. Assignment rule is no dll file use..
[no name] 26-Aug-13 14:10pm    
You would need to go back to your teacher and find out what that means. Just using anything out of the .NET framework, you would be using a DLL. So your requirement makes no sense.
Zoltán Zörgő 26-Aug-13 14:20pm    
That's it. No dlls, no .net application at all :( But the rest of the requirement makes as less sense, thus abbaspirmoradi's comment is really suitable as answer :)
In .NET 4 onward, you can use a BigInteger instance as you would use any other integral type. BigInteger overloads the standard numeric operators to enable you to perform basic mathematical operations such as addition, subtraction, division, multiplication, subtraction, negation, and unary negation.

Ref: http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx[^]
 
Share this answer
 
Comments
Thomas Daniels 26-Aug-13 13:23pm    
+5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900