Why Doesn't Fortran Recognize Small Numbers?

  • Fortran
  • Thread starter womfalcs3
  • Start date
  • #1
womfalcs3
62
5
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?
 

Answers and Replies

  • #2
AUMathTutor
498
0
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.
 
  • #3
womfalcs3
62
5
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.
 
  • #4
womfalcs3
62
5
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.
 

Suggested for: Why Doesn't Fortran Recognize Small Numbers?

  • Last Post
Replies
1
Views
147
  • Last Post
4
Replies
107
Views
2K
  • Last Post
Replies
12
Views
595
  • Last Post
Replies
0
Views
39
  • Last Post
Replies
8
Views
611
Replies
5
Views
1K
Replies
0
Views
801
  • Last Post
Replies
4
Views
628
Top