estart=1.011020poine=1.1019999E-2eunit=0.0001idive=int((estart-poine)/eunit)end(estart-poine)/eunit=10000.00but idive=9999on pgf90 the idive=10000
what's the matter?Thank!
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!
Thank you very much!I have change to :real*8 tttt=dble((estart-poine)/eunit)
in my little test code i get tt:debug: 9999.99971245415release: .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?
Thank!I have change to:
program testreal*8 ttestart=.1011019945145d+01 !get from my whole programpoine=.1101999916136d-01 !get from my whole programeunit=.9999999747379d-04 !get from my whole programprint '(e18.13)',eunittt=(estart-poine)/eunitprint '(e18.13)',ttidive=int(tt)print*,idiveend
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!