[Thread Prev][Thread Next][Index]

Re: [ferret_users] Function MOD : strange behavior



For the integer division, there is often a difference between the computer implementation and the generally accepted definition in math. See https://en.wikipedia.org/wiki/Modular_arithmetic for the definition of modulo and congruence : the result of modulo is always positive.

In computer, there is a difference between the "truncated division" (also called "symmetric") and the "floored division". Most langage implement the truncated division, when the math definition is the "floored division". And I agree that modulo and integer division should be compatible to get (m div n) * n + (m mod n) == m

In Fortran, MOD and MODULO functions have different behaviour with negative numbers !! I'm afraid Fortran misses a floored division (?)

This could be a long discussion about math, computer implementation, etc ...

But my point is far more practical : I define some geographical areas with mask from latitude and longitude values. The work would be simpler if I could use a MOD (or MODULO or whatever) function that return a number in [0,360[, and not in ]-360,360[

For instance : 

I have data with longitude in [0,360]. I want to mask some of them, and plot them f ">Regards,
Ryo


Attachment: smime.p7s
Description: S/MIME cryptographic signature


[Thread Prev][Thread Next][Index]