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

Why Doesn't Fortran Recognize Small Numbers?

  1. Apr 9, 2009 #1
    We're not talking very small. Is it the compiler? I'm using gfortran.

    An example would be:

    f(y)=1E-5*(y**3)

    For f(40), that should be 0.64. When I compile and execute, however, it displays 0's.

    If I make the coefficient 1, the result does come out to be correct.


    I have an old Fortran IV (I'm using F77) book that says for that version of the code, I can't do 1.E-76.

    This is well closer to 1 than that. They even used an example where the power of 10 was -21. So is this right? Is it a problem with the compiler?
     
  2. jcsd
  3. Apr 9, 2009 #2
    It sounds like your problem is one of the following things:
    You are using too low a precision data type, perhaps real (4 bytes) and not double...
    Your types are mismatched and it's demoting types...
    There's some other problem.

    I think you'd get more feedback with more context.
     
  4. Apr 9, 2009 #3
    Ah double precision statements. I didn't think of that. I was trying to use periods, which weren't working, but I've seen people use them for that purpose.

    Thank you. I read up on double precision statements and it was simple enough to incorporate.

    That worked.
     
  5. Apr 25, 2009 #4
    Rather than make a new thread, I figured I'd ask here.

    Is there anyway to define functions after the input type statements?

    For example, f(x)=sin(x). I want to redefine f(x) as I go along the program.

    Thanks.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Why Doesn't Fortran Recognize Small Numbers?
  1. Why not fortran? (Replies: 4)

Loading...