Maximum value display....
-
Hello everyone....i got struck while creating a numeric list of all numbers between 0 to 10 pow 100..... double supports till 308 but it prints like 1E+100 is there any way that i can get value in digits rather than 1E.....
-
YourNumber.ToString("F");
is the only way I am aware of.It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
no not showing digits...it's displaying same 1E+100.....
-
no not showing digits...it's displaying same 1E+100.....
-
I just tried following code:
string str = double.MaxValue.ToString("f");
Works fine for me.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
Thnx alot bro...:) it's workin great....but is there any way to get rid off those .00 at last....
-
Thnx alot bro...:) it's workin great....but is there any way to get rid off those .00 at last....
sry lol....actually it's representing a fixed digit....not that number i wanted.... double dl = Math.pow(10,100); i want to get dl in digits rather than E....and that max value one is showing some fixed digit that also float it has .00 at last....
-
sry lol....actually it's representing a fixed digit....not that number i wanted.... double dl = Math.pow(10,100); i want to get dl in digits rather than E....and that max value one is showing some fixed digit that also float it has .00 at last....
-
This would help:
Math.Pow(10, 100).ToString("f0");
The digit after "f" specifies number of digits after decimal.It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
the thing you told is good for printing 1 and 0's only...try this double dl = Math.Pow(10, 100); double dll = dl + 21; string ss = dll.ToString("f0"); Console.Write(ss); Console.Read(); n tell how to work on that digit...it's not showing the change....
-
Hello everyone....i got struck while creating a numeric list of all numbers between 0 to 10 pow 100..... double supports till 308 but it prints like 1E+100 is there any way that i can get value in digits rather than 1E.....
Hi, your problem is not related to the formatting string in some ToString() method, it is much more fundamental. real numbers are not capable of storing all the information that would be required to show all the digits of large numbers, that is exactly why they show at most 7 (float) or 16 (double) digits and tell you by which power of 10 the number needs to be multiplied. integers keep all information accurately until they reach their maximum value; for int (Int32) that would be around 2 billion, much less than what you want. To store your 10^100 value as an integer, one would need over 300 bytes, whereas regular integers only hold 4 or 8 bytes of data. decimals are somewhere in the middle, they won't solve it either. What you need is some special type, often called BigInt, BigInteger, BigNumber; google for those. There are some articles here on CodeProject about them. And C# 4.0 holds a class that could help you. :)
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
-
Hi, your problem is not related to the formatting string in some ToString() method, it is much more fundamental. real numbers are not capable of storing all the information that would be required to show all the digits of large numbers, that is exactly why they show at most 7 (float) or 16 (double) digits and tell you by which power of 10 the number needs to be multiplied. integers keep all information accurately until they reach their maximum value; for int (Int32) that would be around 2 billion, much less than what you want. To store your 10^100 value as an integer, one would need over 300 bytes, whereas regular integers only hold 4 or 8 bytes of data. decimals are somewhere in the middle, they won't solve it either. What you need is some special type, often called BigInt, BigInteger, BigNumber; google for those. There are some articles here on CodeProject about them. And C# 4.0 holds a class that could help you. :)
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
Thnx alot....i don't wanna get into generating digits individually using multidimensional string array or char array and concatenating them......
-
Hello everyone....i got struck while creating a numeric list of all numbers between 0 to 10 pow 100..... double supports till 308 but it prints like 1E+100 is there any way that i can get value in digits rather than 1E.....
Oh, and one more thing:
greendragons wrote:
all numbers between 0 to 10 pow 100
assuming you meant integer numbers only, stored in memory this would take more memory than your system holds; printed on paper this will take more paper than would fit in your house; and if you were to generate somehow say 10^50 numbers each second (not sure how you would do that with a CPU running at a few 10^9 instructions per second), it would take you 10^50 seconds, which is longer than the universe has existed till now. So next time, do a little reality check before you set out for a project like this. :)
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!