存储超过2功率31在32位系统上 [英] storing more than 2 power 31 on a 32-bit system

查看:117
本文介绍了存储超过2功率31在32位系统上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须写一个程序,可以计算出的 2的功率2010 的权力,并找到的数字之和。例如:

I have to write a program that can calculate the powers of 2 power 2010 and to find the sum of the digits. eg:

if `2 power 12 => gives 4096 . So 4+0+9+6 = 19 . 

现在我需要找到同为 2的功率2010

请帮我明白了。

推荐答案

下面的东西,让你开始:

Here's something to get you started:

char buf[2010]; // 2^2010 < 10^2010 by a huge margin, so buffer size is safe
snprintf(buf, sizeof buf, "%.0Lf", 0x1p2010L);

这篇关于存储超过2功率31在32位系统上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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