I am doing 2^1000 and I am getting this:
1.07151e+301
Is there any way to actually turn this into a proper number without the e+301, or at least can anyone show me where I can see how to turn this in to a real number, by some way working with the e+301 part?
Unfortunately excel does not allow you to turn this functionality off by default. However if you select your data, right click, and click "Format cells..." and choose Number you can stop excel from changing your data to scientific notation.
Scientific notation is a way of writing very large or very small numbers. A number is written in scientific notation when a number between 1 and 10 is multiplied by a power of 10. For example, 650,000,000 can be written in scientific notation as 6.5 ✕ 10^8.
If you want to avoid scientific notation for a given number or a series of numbers, you can use the format() function by passing scientific = FALSE as an argument.
you can right click on the cell and choose Format cell and change the format from general to number with zero number of decimal places.
So, I'm thinking that what you really want is just the ability to print it without scientific notation. If you're using printf
, what you want is:
printf( "%f1000.0", value );
// note that 1000 is way larger than need be,
// I'm just too lazy to count the digits
With cout
, try something like:
cout.setf(ios::fixed);
cout << setprecision(0) << value;
If you want to print it as a power of two (2^1000 vs 10715...), you're on your own.
There is a practical limit to how large a number that can be directly manipulated in machine registers can be. if you are using double precision floats there are a total of 64 bits, some of which are devoted to the mantissa, some to the exponent, and 1 to the sign bit.
2^1000 needs a 1001 bit integer to be represented without losing precision. In order to work with numbers like that you will need to use a library that has big number support, such as GNU MP.
You need to use a number class specifically designed for long numbers.
To represent 2^1000 as an exact number then by definition you need a number format that actually holds 1001 binary bits. The longest normal primitive integer format is usually only 64 bits.
BTW, the answer is:
% perl -Mbigint -e 'print 2**1000'
10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With