[Jprogramming] Puzzling result

Erling Hellenäs erling at erlinghellenas.se
Wed Sep 13 15:23:46 UTC 2017


Floor and ceiling and eq in j all uses comparison tolerance, So when the 
result is set to 0 if floor and ceiling are equal in the J sense, we get 
the zero result. The question s then if this is the correct behaviour.

As we can see floor uses comparison tolerance. It is not obvious to me 
why. It is not a comparison. If it didn't, we would get the correct result.

Another possibility is to use comparison tolerance = 0 for floor and 
ceiling only here, if that would be what we consider correct behaviour.

      q=: 5729082486784839 % 196

      30j5":q
29230012687677.75000
      30j5":<.q
29230012687678.00000
      30j5":>.q
29230012687678.00000
      30j5":(>.q) = <.q
1.00000


9!:19]0


30j5":q

29230012687677.75000

30j5":<.q

29230012687677.00000

30j5":>.q

29230012687678.00000

30j5":(>.q) = <.q

0.00000


Cheers,


Erling



Den 2017-09-13 kl. 16:34, skrev Raul Miller:
> Hmm... actually... no...
>
> The relevant implementation here is in ve.c:
>
> static D jtremdd(J jt,D a,D b){D q,x,y;
>   if(!a)R b;
>   ASSERT(!INF(b),EVNAN);
>   if(a==inf )R 0<=b?b:a;
>   if(a==infm)R 0>=b?b:a;
>   q=b/a; x=tfloor(q); y=tceil(q); R teq(x,y)?0:b-a*x;
> }
>
> No hint of fmod here (though it does get used elsewhere).
>
> FYI,
>



More information about the Programming mailing list