Reputation: 709
The following program print 1 for 100E-2
and gives 0 for 100*10**(-2)
, that means that
the operator exponent doesnot work for negative **
, is that correct.
Thanks in advance
program testme
implicit none
print*,100E-2
print*,100*10**(-2)
end program
Upvotes: 1
Views: 3259
Reputation: 50937
You'll notice that the second print statement prints 0
-- no decimal pt, etc. Eg, integer zero. That's because 10
by itself is an integer literal, and raising that to the negative 2 power correctly gives zero; multiplying it by integer 100 still gives integer zero.
If you instead use
print*,100*10.**(-2)
you'll get the answer you expect.
The issue doesn't arise with 100e-2
because any number expressed with scientific notation is a floating point (real
) literal.
Upvotes: 3