如何避免大量使用科学计数法? [英] How do I avoid scientific notation for large numbers?

查看:90
本文介绍了如何避免大量使用科学计数法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做2 ^ 1000,我正在得到这个:

I am doing 2^1000 and I am getting this:

1.07151e + 301

1.07151e+301

是否有任何方法可以在没有e + 301的情况下将其实际转换为正确的数字,或者至少有人可以告诉我在哪里可以看到通过某种方式与e +一起将其转换为实数的方法. 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?

推荐答案

因此,我在想,您真正想要的只是无需科学表示就可以打印它的功能.如果您使用的是printf,则需要的是:

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

使用cout,尝试类似的操作:

With cout, try something like:

cout.setf(ios::fixed);
cout << setprecision(0) << value;

如果您想将其打印为2的幂(2 ^ 1000与10715 ...),那么您就该靠自己了.

If you want to print it as a power of two (2^1000 vs 10715...), you're on your own.

这篇关于如何避免大量使用科学计数法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆