关于Objective-C的biginteger [英] biginteger on Objective-c

查看:103
本文介绍了关于Objective-C的biginteger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以为 BigInteger提供代码在Objective-c中提供PowMod函数的实现?

Can anyone provide code for a BigInteger implementation in objective-c that provides a PowMod function ?

推荐答案

我希望回答这个话题还为时不晚.

I hope it's not too late to answer this thread.

您可以尝试免费使用" LibTomMath "(作者放弃了该项目,将其作为公共领域).它开箱即用,无需任何配置,只需将所有bn _ *.c和tommath * .h放入您的Xcode项目中,即可开始使用.

You can try "LibTomMath" which is opensource and free (the author give away this project as public domain). It works out of the box without any configuration, just put all bn_*.c and tommath*.h to your Xcode project and you are ready to go.

#import "tommath.h"

mp_int number1, number2, number3;

mp_init(&number1);
mp_init(&number2);
mp_init(&number3);

mp_read_radix(&number1, "0a120edfff558c98a73015d5d67e8990", 16);
mp_read_radix(&number2, "12e6f45d698c7b7009a841c1348d6ff4", 16);

mp_mul(&number1, &number2, &number3);

char output[1000];
mp_toradix(&number3, output, 16);
NSLog(@"number3:%s", output);

mp_div(&number3, &number1, &number2, NULL);
mp_toradix(&number2, output, 16);
NSLog(@"number2:%s", output);

这篇关于关于Objective-C的biginteger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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