I need to represent 10 raised to the power of 100 (10 E 100) in a c program. Does C have a datatype that can do this natively?
I need to represent 10 raised to the power of 100 (10 E 100) in a c program. Does C have a datatype that can do this natively?
You mean like:
Code:itsme@itsme:~/C$ cat float.c #include <stdio.h> int main(void) { double close_to_pi = 22./7.; printf("%e\n", close_to_pi); return 0; }Code:itsme@itsme:~/C$ ./float 3.142857e+00
If you understand what you're doing, you're not learning anything.
Not exactly. I am trying to represent this number: 10000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 0. And I can't find a datatype large enough to represent it.
long long (in C99)? A long long variable usually occupies 64 bits.
Take itsme86's example. A double can easily hold that number. But there might be some loss of precision.
Code:#include <stdio.h> int main(void) { double big = 1e100; printf("%f\n", big); return 0; }
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Thanks. :-)