# int(10000.00)=9999

## int(10000.00)=9999

estart=1.011020
poine=1.1019999E-2
eunit=0.0001
idive=int((estart-poine)/eunit)
end
(estart-poine)/eunit=10000.00
but idive=9999
on pgf90 the idive=10000

what's the matter?
Thank!

6 post / 0 new
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

program test
estart=1.011020
poine=1.1019999E-2
eunit=0.0001
idive=int((estart-poine)/eunit)
print*,idive
end

on release: idive=10000,
on debug: idive=9999

but in my whole program idive=9999 on both release and debug!
the type of poine,eunit,estart is real,and in my whole program, the poine,estart are the result of calculation.

lihm,
I think that you are having problems because of the precision of the real numbers that you are using. Standard REALs can hold about 6 significant digits. The expression in the brackets that you are taking the INT of only differs from 1000 in the 10th significant figure. The INT will calculate 9999 if it's slightly below or 10000 if slightly above. Different compilers, and different releases in CVF, may calculate things slightly differently, giving slightly different real answers. For your example, I think that using DOUBLE PRECISION would give the answer you expect, as would using NINT rather than INT. Exactly what's best to do will depend on your overall calculation. This is just one of those areas where you need to be careful how you use real numbers!

Joe

Thank you very much!
I have change to :
real*8 tt
tt=dble((estart-poine)/eunit)

in my little test code i get tt:
debug: 9999.99971245415
release: .1000000000000E+05

but in my whole program,I get tt:
9999.99971245415
.9999999712454E+04

as you said about NINT,it is not right for my program for i need the largest integer little than the real number .

Have you changed the literal constant 10000. in your code with 10000.d0 or 10000._8 as well?

Jugoslav www.xeffort.com

Thank!
I have change to:

program test
real*8 tt
estart=.1011019945145d+01 !get from my whole program
poine=.1101999916136d-01 !get from my whole program
eunit=.9999999747379d-04 !get from my whole program
print '(e18.13)',eunit
tt=(estart-poine)/eunit
print '(e18.13)',tt
idive=int(tt)
print*,idive
end

It is as before too,I think maybe just because the estrart,poine and eunit have littel difference between this two progranm.I will add some judge code to my whole program in order to can run on linux well.
thank!