Problem in integer declaration

  • 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.
 

Related to Problem in integer declaration

1. 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.

2. 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.

3. 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.

4. 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.

5. 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

  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
3
Views
3K
Replies
9
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
6
Views
953
  • Programming and Computer Science
Replies
8
Views
3K
  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
Back
Top