19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Here we present only the trait Q and its methods. <strong>The</strong> other rational types have exactly the same methods and differ<br />

only in the details of the types of method arguments and results and exactly what traits are extended by each rational<br />

type. For example, Q is a field and is totally ordered, Q ∗ is totally ordered but is not a field, and Q # is neither<br />

totally ordered nor a field. For the exact details of how all this is implemented, see Section 38.1.<br />

trait Q<br />

extends { R, Q ∗ ,<br />

FieldQ, Q≠, +, −, ·, /,<br />

FieldQ, Q≠, +, −, ×, /,<br />

FieldQ, Q≠, +, −,juxtaposition, /,<br />

TotalOrderOperatorsQ, ,CMP }<br />

coercion ( : Identity+) = 0<br />

coercion ( : Identity·) = 1<br />

coercion ( : Identity×) = 1<br />

coercion ( : Identityjuxtaposition) = 1<br />

coercion ( : Zero·) = 0<br />

coercion ( : Zero×) = 0<br />

coercion ( : Zerojuxtaposition) = 0<br />

opr juxtaposition (self,other: Q): Q<br />

opr +(self): Q<br />

opr +(self,other: Q): Q<br />

opr −(self): Q<br />

opr −(self,other: Q): Q<br />

opr ·(self,other: Q): Q<br />

opr ×(self,other: Q): Q<br />

opr /(self): Q ∗<br />

opr /(self,other: Q): Q #<br />

opr _(self,power: Z): Q #<br />

opr (self,other: Q): Boolean<br />

opr CMP(self,other: Q ∗ ):TotalComparison<br />

opr CMP(self,other: Q # ):Comparison<br />

opr MAX(self,other: Q): Q<br />

opr MIN(self,other: Q): Q<br />

opr MAXNUM(self,other: Q): Q<br />

opr MINNUM(self,other: Q): Q<br />

opr |self| : Q ≥<br />

signum(self): Z<br />

numerator(self): Z<br />

denominator(self): Z<br />

floor(self): Z<br />

opr ⌊self⌋: Z<br />

ceiling(self): Z<br />

opr ⌈self⌉: Z<br />

round(self): Z<br />

truncate(self): Z<br />

opr ⌊self ⌋: N<br />

opr ⌈self ⌉: N<br />

opr ⌊self ⌋: N<br />

194

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!