大整数 [英] large integers

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

问题描述

如果我有一个值,比如说13849,我可以将它分配给x并测试它是否可以分割

由37这样的东西,如

if(x%37 = = 0)...

我可以通过类似

int y;

y = sqrt(x)来测试它是否是正方形);

if(x == y * y)...


但我的问题是,我怎么能做这两件事(最好是简单的如果我的价值不是13849,而且比如176457628349?


Tim

If I have a value, say 13849, I can assign it to x and test if it divisible
by 37 by something like
if (x%37==0)...
and I can test if it''s a square by something like
int y;
y=sqrt(x);
if (x==y*y)...

But my question is, how can I do these two things (preferably as simply and
efficiently as possible) if my value is not 13849, but, say, 176457628349?

Tim

推荐答案

Tim S Roberts写道:
Tim S Roberts wrote:

如果我有一个值,比如13849,我可以将它分配给x并测试它是否

可被37整除如

if(x%37 == 0)...

我可以测试它是否'' sa square by

int y;

y = sqrt(x);

if(x == y * y)...


但我的问题是,我怎么能做这两件事(最好是简单有效地作为b / b
)如果我的价值不是13849,但是,

说,176457628349?
If I have a value, say 13849, I can assign it to x and test if it
divisible by 37 by something like
if (x%37==0)...
and I can test if it''s a square by something like
int y;
y=sqrt(x);
if (x==y*y)...

But my question is, how can I do these two things (preferably as
simply and efficiently as possible) if my value is not 13849, but,
say, 176457628349?



如果您的编译器支持的数字范围包含您的

176457628349,请使用该类型。您必须在新闻组中询问

是否有关于它的编译器,或者阅读手册(哎呀,我刚刚写了

那个?)


-

请在通过电子邮件回复时删除资金''A'

我不回复热门回复,请不要问

If your compiler supports numbers with the range that includes your
176457628349, use that type. You would have to ask in the newsgroup
for your compiler about it, or read the manual (oops, did I just write
that?)

--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask




" Victor Bazarov" < v。******** @ comAcast.netwrote in message

news:eg ********** @ news.datemas.de ...

"Victor Bazarov" <v.********@comAcast.netwrote in message
news:eg**********@news.datemas.de...

Tim S Roberts写道:
Tim S Roberts wrote:

>如果我有一个值,比如13849,我可以分配它到x并测试它是否可以通过类似
的整数除以/如果(x%37 == 0)...
我可以测试它是否是像
int y;
y = sqrt(x);
如果(x == y * y)...

但我的问题是,我怎么办如果我的价值不是13849,那么这两件事(最好是尽可能简单有效),但是,
说,176457628349?
>If I have a value, say 13849, I can assign it to x and test if it
divisible by 37 by something like
if (x%37==0)...
and I can test if it''s a square by something like
int y;
y=sqrt(x);
if (x==y*y)...

But my question is, how can I do these two things (preferably as
simply and efficiently as possible) if my value is not 13849, but,
say, 176457628349?



如果您的编译器支持的数字范围包含您的

176457628349,请使用该类型。您必须在新闻组中询问

您的编译器,或阅读手册(哎呀,我刚刚写了

那个?)


If your compiler supports numbers with the range that includes your
176457628349, use that type. You would have to ask in the newsgroup
for your compiler about it, or read the manual (oops, did I just write
that?)



谢谢你 - 但我不认为我有这样的类型(我正在使用

Microsoft Visual C ++ 6.0)。我可以使用任何变通方法吗?或者我将要
必须使用Mathematica,或者其他东西(问题是,我使用的是非常大的

数字,*和*我需要速度...... )


Tim

Thanks for this - but I don''t think I have such a type available (I''m using
Microsoft Visual C++ 6.0). Are there any workarounds I can use? Or will I
have to use Mathematica, or something (the problem is, I''m using very large
numbers, *and* I need speed....)

Tim


Tim S Roberts写道:
Tim S Roberts wrote:

如果我有一个值,比如说13849,我可以将它分配给x并测试它是否可以分割

×37,如

if(x%37 == 0) ...

我可以测试它是否是像

int y;

y = sqrt(x);

if(x == y * y)...


但我的问题是,我怎么能做这两件事(最好是简单地和

尽可能有效)如果我的价值不是13849,但是,比方说,176457628349?


Tim
If I have a value, say 13849, I can assign it to x and test if it divisible
by 37 by something like
if (x%37==0)...
and I can test if it''s a square by something like
int y;
y=sqrt(x);
if (x==y*y)...

But my question is, how can I do these two things (preferably as simply and
efficiently as possible) if my value is not 13849, but, say, 176457628349?

Tim



一些编译器(例如g ++)支持__int64数据类型。


__int64 BigIntVar =(__ int64)176457628349LL;

cout<< (BigIntVar%37)<< endl;


- 马丁

Some compilers (e.g. g++) support the __int64 datatype.

__int64 BigIntVar = (__int64) 176457628349LL;
cout << (BigIntVar % 37) << endl;

- Martin


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

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