Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem in integer declaration

  1. Aug 9, 2008 #1
    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?

  2. jcsd
  3. Aug 9, 2008 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    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?
  4. Aug 9, 2008 #3


    Staff: Mentor

    Wikipedia can help. Look at the arbitrary-precision arithmetic page.
  5. Aug 9, 2008 #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. :)
  6. Aug 9, 2008 #5
    python handles large numbers natively.
  7. Aug 10, 2008 #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.
  8. Aug 13, 2011 #7
    For integers of that size, use IBM's PL/I, which caters for integers less than 10**32.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Problem in integer declaration