request for INT2RAT conversion operator

This forum is for any questions about the language Tutorial D or the Rel implementation of it.
Post Reply
HughDarwen
Posts: 124
Joined: Sat May 24, 2008 4:49 pm

request for INT2RAT conversion operator

Post 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
Dave
Site Admin
Posts: 372
Joined: Sun Nov 27, 2005 7:19 pm

Re: request for INT2RAT conversion operator

Post 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.
HughDarwen
Posts: 124
Joined: Sat May 24, 2008 4:49 pm

Re: request for INT2RAT conversion operator

Post by HughDarwen »

Oops! Sorry to have bothered you. A case of RTFM I suppose.

Chastened,
Hugh
Dave
Site Admin
Posts: 372
Joined: Sun Nov 27, 2005 7:19 pm

Re: request for INT2RAT conversion operator

Post 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.
Post Reply