The curious case of OPERATOR ABS(INTEGER).

This forum is to report technical problems with Rel.
Post Reply
Posts: 49
Joined: Sun Sep 01, 2013 10:53 pm

The curious case of OPERATOR ABS(INTEGER).

Post by steved »

I've been meaning to bring this to your attention for some time so here it is. There is an easy workaround
but if you are unaware of this problem it can cause serious grief :D
Running Relv3.010 on WINDOWS 10.

It would seem ABS(INTEGER) always incorrectly displays a rational but is correctly recognized as an integer.

Code: Select all

WRITELN ABS(14) ;                   //14.0
WRITELN ABS(7);                      //7.0
WRITELN ABS(-5) ;                   //5.0
WRITELN ABS ( (-15*2)/5);      //6.0
WRITELN TYPE_OF(ABS(1));                    //Scalar("INTEGER")
WRITELN TYPE_OF(ABS(-1));                  //Scalar("INTEGER")
WRITELN REL{TUP{X1 ABS(4), X2 4.0},TUP{X1 ABS(-5), X2 -5.0}} ;
     TUPLE {X1 4.0, X2 4.0},
     TUPLE {X1 5.0, X2 -5.0}
But then there is this confusion.

Code: Select all

WRITELN  ABS(-5)*2  ;                        //ERROR: RS0278: No run-time invocation targets found for OP_TIMES(RATIONAL, INTEGER) RETURNS INTEGER  

WRITELN TYPE_OF ( ABS(-5)*2 ) ;        //Scalar("INTEGER")

WRITELN TYPE_OF ( ABS(-5)*2.0 ) ;     //ERROR: RS0055: Could not find operator OP_TIMES(INTEGER, RATIONAL) RETURNS RATIONAL

Site Admin
Posts: 368
Joined: Sun Nov 27, 2005 7:19 pm

Re: The curious case of OPERATOR ABS(INTEGER).

Post by Dave »

Thanks for finding this. I've added it to my "to do" list.
Post Reply