Page 1 of 1

request for INT2RAT conversion operator

Posted: Tue Sep 28, 2010 11:37 am
by HughDarwen
I don't mean that the operator name has to be INT2RAT as in my subject line, but I wonder if it would be possible for such an operator to be included in, say, OperatorsMath.d (or even supplied as built-in).

I ran into this requirement when I was trying to compare some real students' real exam scores with the computed average (you see, I do use Rel for "real" as well as for teaching!). The scores are values of type INTEGER whereas AVG(score) yields a value of type RATIONAL.

Hugh

Re: request for INT2RAT conversion operator

Posted: Wed Sep 29, 2010 8:25 am
by Dave
CAST_AS_RATIONAL is a built-in operator. E.g.:

Code: Select all

CAST_AS_RATIONAL(2)
2.0
The sys.OperatorsBuiltin relvar contains signatures for most of the built-in operators.

Re: request for INT2RAT conversion operator

Posted: Wed Sep 29, 2010 11:53 am
by HughDarwen
Oops! Sorry to have bothered you. A case of RTFM I suppose.

Chastened,
Hugh

Re: request for INT2RAT conversion operator

Posted: Wed Sep 29, 2010 2:19 pm
by Dave
No bother at all! I have to admit I'd forgotten the name of the operator and had to look it up. :oops:

This also gives me the opportunity to point out that built-in operators also appear in the sys.Operators relvar. sys.OperatorsBuiltin contains built-in operators not associated with any particular TYPE definition. sys.Operators contains, by default, operators specifically generated by and associated with the built-in TYPE definitions.