How to Declare Extremely Large Integers in Fortran 90?

  • Context: Fortran 
  • Thread starter Thread starter Sadjad
  • Start date Start date
  • Tags Tags
    Integer
Click For Summary

Discussion Overview

The discussion revolves around the challenges of declaring extremely large integers in Fortran 90, particularly in relation to representing values like Avogadro's number (6.022 x 1023). Participants explore various approaches and considerations regarding the limitations of integer types in programming languages.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses the need to declare an integer in Fortran 90 that can support very large numbers, specifically Avogadro's number.
  • Another participant suggests that no programming language typically supports integer variables of that magnitude and proposes using separate long-integer variable types to store digits.
  • A different viewpoint questions the necessity of storing Avogadro's number as an integer, noting that only a limited number of digits are known accurately.
  • Some participants mention that other languages, such as Java, PHP, and C#, have built-in support for large integers through classes like BigInteger, while expressing uncertainty about Fortran's capabilities.
  • One participant suggests that working in terms of moles could eliminate the need for such large integers.
  • Another participant mentions IBM's PL/I as a language that can handle integers less than 1032.

Areas of Agreement / Disagreement

Participants generally agree that standard integer types in programming languages do not support extremely large values, but there is no consensus on the best approach to handle such large numbers in Fortran 90. Multiple competing views regarding the necessity and methods of representing large integers remain unresolved.

Contextual Notes

Participants highlight limitations in the accuracy of known digits for Avogadro's number and the potential need for custom implementations to handle large integers in Fortran.

Sadjad
Messages
2
Reaction score
0
Dear all,

I have a problem with Fortran 90. I want to declare an integer which is enable to support till numbers such as Avogadro number (6.022*10**23). I use "Microsoft Fortran PowerStation 4.0". Can anyone can help me please?

Regards,
 
Technology news on Phys.org
I've never heard of any language that supports integer variables that high. You could probably write some routine where the digits are stored in many separate long-integer variable types.

But a question is, why not just work in terms of moles, so that you don't need such large numbers?
 
Wikipedia can help. Look at the http://en.wikipedia.org/wiki/Bignum" page.
 
Last edited by a moderator:
What is the point of storing Avagadro's number as an integer? We only know the first 8 digits accurately, so you will have fifteen zeros trailing after those digits.

Languages like java, php, C# have a biginteger class that supports such large numbers, but I don't know about Fortran. You could write your own biginteger functions which would be interesting and instructive though. :)
 
Redbelly98 said:
I've never heard of any language that supports integer variables that high. You could probably write some routine where the digits are stored in many separate long-integer variable types.

But a question is, why not just work in terms of moles, so that you don't need such large numbers?

python handles large numbers natively.
 
Thank you to all,

To Redbelly98: I have to work with molecules, since the model which I going to model is on the molecules.

To ceptimus: I am with you. It's better not to declare it as an integer because the reason you mentioned.
 
Redbelly98 said:
I've never heard of any language that supports integer variables that high. You could probably write some routine where the digits are stored in many separate long-integer variable types.

For integers of that size, use IBM's PL/I, which caters for integers less than 10**32.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 17 ·
Replies
17
Views
6K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 17 ·
Replies
17
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 3 ·
Replies
3
Views
2K