How to Declare Extremely Large Integers in Fortran 90?

  • Thread starter Thread starter Sadjad
  • Start date Start date
  • Tags Tags
    Integer
AI Thread Summary
Fortran 90 does not support integer declarations capable of handling extremely large numbers like Avogadro's number (6.022 x 10^23). Users suggest alternative approaches, such as working in moles to avoid the need for such large integers. While some programming languages like Java, PHP, and C# offer a BigInteger class for large numbers, Fortran lacks this feature. Users recommend creating custom routines to manage large integers by storing digits in separate long-integer variables. Additionally, IBM's PL/I is mentioned as a language that can handle integers up to 10^32, providing a potential solution for those needing to work with large numerical values in their models.
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
Views
1K
Replies
3
Views
2K
Replies
3
Views
3K
Replies
17
Views
6K
Replies
8
Views
4K
Replies
4
Views
3K
Replies
3
Views
2K
Replies
8
Views
4K
Back
Top