How to Declare Extremely Large Integers in Fortran 90?

  • Thread starter Sadjad
  • Start date
  • Tags
    Integer
In summary, the person is trying to work with a model that uses molecules and they are looking for help with a language that can handle large integers. They mention that Python can handle large numbers natively.
  • #1
Sadjad
2
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
  • #2
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?
 
  • #3
Wikipedia can help. Look at the http://en.wikipedia.org/wiki/Bignum" page.
 
Last edited by a moderator:
  • #4
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. :)
 
  • #5
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.
 
  • #6
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.
 
  • #7
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.
 

FAQ: How to Declare Extremely Large Integers in Fortran 90?

What is a problem in integer declaration?

A problem in integer declaration is an error that occurs when trying to assign a value to an integer variable that is either too large or too small to be stored in that variable's data type. This can result in unexpected behavior or program crashes.

How can I avoid problems in integer declaration?

To avoid problems in integer declaration, it is important to make sure that the value being assigned to an integer variable falls within the range of that variable's data type. For example, if the variable is declared as an int, the value should be between -2,147,483,648 and 2,147,483,647. If the value is outside of this range, consider using a different data type such as a long or double to store larger numbers.

What are some common causes of problems in integer declaration?

Common causes of problems in integer declaration include assigning a value that is too large or too small for the data type, using the wrong data type for the value being assigned, or forgetting to declare the variable altogether. It is important to carefully check the data types and values being used when declaring and assigning integer variables.

How can I troubleshoot problems in integer declaration?

If you encounter a problem in integer declaration, the first step is to carefully check the data types and values being used. Make sure that the variable is declared with the correct data type and that the value being assigned falls within the range of that data type. You may also want to use debugging tools or print statements to track the values of your variables and see where the error is occurring.

Can problems in integer declaration be fixed?

Yes, problems in integer declaration can be fixed by correcting the data types and values used in the declaration and assignment of the variable. It is important to carefully check for any potential errors and make sure that the values being used are appropriate for the data type being used.

Similar threads

Replies
2
Views
1K
Replies
3
Views
2K
Replies
3
Views
3K
Replies
17
Views
5K
Replies
8
Views
4K
Replies
4
Views
3K
Replies
3
Views
2K
Replies
8
Views
4K
Back
Top