[Thread Prev][Thread Next][Index]

[ferret_users] Function MOD : strange behavior



In pyferret 7.5 : 


yes? LET lon=I[I=1:10]*36
yes? LIST MOD(lon    ,360), MOD(lon-360,360), MOD(lon-720,360), MOD(lon+360,360)
             X: 0.5 to 10.5
 Column  1: EX#1 is MOD(LON    ,360)
 Column  2: EX#2 is MOD(LON-360,360)
 Column  3: EX#3 is MOD(LON-720,360)
 Column  4: EX#4 is MOD(LON+360,360)
            EX#1   EX#2   EX#3   EX#4
1    /  1:   36.0 -324.0 -324.0   36.0
2    /  2:   72.0 -288.0 -288.0   72.0
3    /  3:  108.0 -252.0 -252.0  108.0
4    /  4:  144.0 -216.0 -216.0  144.0
5    /  5:  180.0 -180.0 -180.0  180.0
6    /  6:  216.0 -144.0 -144.0  216.0
7    /  7:  252.0 -108.0 -108.0  252.0
8    /  8:  288.0  -72.0  -72.0  288.0
9    /  9:  324.0  -36.0  -36.0  324.0
10   / 10:    0.0    0.0   -0.0    0.0


The result of EX#2 and EX#3 puzzles me. From what I remember from my math studies, the MOD function should return a result in the interval [0,360[. All EX#s should print the same result than EX#1 and EX#4.

Is this a bug or a feature ? If this is a feature, it should be at last documented. And another MOD function with the "correct" behaviour would be strongly appreciated ;-)

Olivier

— 
Olivier Marti  - LSCE Bât 714 p. 1049
MERMAID Team
Normal situation :  +33 1 69 08 77 27 
Corona lockdown  :  +33 6 45 36 43 74

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


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement