fortran - Using Floor and Int in a computation -
i using calculation locate base pixel. seems me 2 calculations , j equivalent (i.e. i==j true) when tried few examples. true?
i = (int ((x - xmin) / a)) + 1 j = (floor ((x - xmin) / a)) + 1 in addition above, following may give different result , j (i.e. there exist situations i/=j).
i = (nint ((x - xmin) / a)) + 1 j = (ceiling ((x - xmin) / a)) + 1
it true in scenario
when value stored in ix 'int' function, ignore float values , consider whole number before decimal point. in case of floor, convert nearest lower whole number.
the difference is: in first case, floats ignored, , in second case- entire number converted.
ultimately, both results same. (only in scenario) recommended use right functions right calculation.
Comments
Post a Comment