开发者

Best programming language for very large arrays and very large numbers?

What would be the best programming language开发者_StackOverflow for very large arrays and very large numbers?

  • With arrays over 30,000 indexes
  • And numbers over 100 digits

Also it needs to be efficient, or easy to make efficient.

Thanks.


Almost any programming language worth its salt should have these characteristics, and frankly I don't think I'd want to use any language that can't handle arrays of 30,000 elements. I'll list a few that have good support for very large numbers:

python. Python 3 has automatic support for large numbers as the default number type grows as necessary, and has some really awesome math libraries. Other languages may be ever so slightly faster, but unless for some reason you know for sure that python won't be good enough I'd start there.

C#. This will mostly bind you to windows, but its very popular, fast, and meets your requirements.

Java. Cross platform, mature support with BigInteger.

Haskell. Pretty seamless conversions to large numbers and powerful math support. If you have a strong mathematics background Haskell will feel pretty natural. If you already know functional programming or don't mind devoting a fascinating few hours to learning it, this is a good choice.

C/C++. Very fast, but a little more complex to develop in. You'll probably get better results in large number support with something else. I'd only look into C++ if you've tried optimizing code in another languages and its still not fast enough, unless you have a specific reason to not use an intermediately compiled language.


The truth of the matter is that its hard to find a programming language that doesn't support these things, and if you could I probably wouldn't use it for anything because its probably not that mature. Do you have any other requirements that would help us narrow it down further for you? :D


The array is not the issue. Numbers consisting of 100 numerals (digits) is a huge issue. I don't have a good answer to the question (out of date as it is) but as this comes up readily in Google I'll mention that most languages only support between 32 to 64 bit numbers. (I know that the C family of languages, PHP, as3 and Java don't support massive numbers.)

For example a 32 bit number would allow a range of 0 to 4,294,967,295 (2^32-1) which is only 10 numerals (Actually more like 9 because the limit is by size, not numerals), a whole order of magnitude less than the required 100 digits the questioner was after.

That said I know that there are cases of people implementing support for large numbers in C and AS3...


Python with NumPy is probably what you want.


I always found Fortran to be quite nice when dealing with arrays, esp. with multi-dimensional ones. If you are dealing with very large numbers, you will probably need to define your own data type or live with a loss of precision, though. Or use this: http://www.fortran.com/big_integer_module.f95 .

But it depends a bit on what you want to do. Fortran is nice for numerical computations, and not so nice for about everything else.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜