存储和在C大数字工作 [英] Store and work with Big numbers in C

查看:113
本文介绍了存储和在C大数字工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助非常大的数字工作。据到Windows计算,​​指数

I need help working with very big numbers. According to Windows calc, the exponent

174^55 = 1.6990597648061509725749329578093e+123 

我将如何保存这一点使用C(C99标准)?

How would I store this using C (c99 standard)?

int main(){
  long long int x = 174^55; //result is 153
  printf("%lld\n", x);
}

这是我们正在实施的RSA加密算法,它有大量的与加密/解密大国的交易幂学校项目。

This is for a school project where we are implementing the RSA cryptographic algorithm, which deals with the exponentiation of large numbers with large powers for encryption/decryption.

推荐答案

普通类型C可通常只能存储多达64位,所以你必须要大的数字,存储在数组中,例如,写数学运算你自己。但你不应该在这里重新发明轮子 - 你可以尝试href=\"http://gmplib.org\"> GNU多precision运算库的用于此目的的

Normal types in C can usually only store up to 64 bits, so you'll have to store big numbers in an array, for example, and write mathematical operations yourself. But you shouldn't reinvent the wheel here - you could try the GNU Multiple Precision Arithmetic Library for this purpose.

和作为评论已经指出的那样, ^ 操作二进制XOR。对于幂,你将不得不使用数学功能,如 POW

And as the comments already pointed out, the ^ operation is binary XOR. For exponentiation, you will have to use mathematical functions like pow.

这篇关于存储和在C大数字工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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