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.

Chapter 38<br />

Numbers<br />

38.1 <strong>The</strong> Trait <strong>Fortress</strong>.Standard.RationalQuantity<br />

<strong>The</strong> standard types for rational numbers such as Q and Q ∗ and Q # ≤<br />

are defined in terms of a single trait RationalQuantity<br />

that handles dimensions and units as well as performing a case analysis to distinguish rather a particular expression is<br />

guaranteed not to produce infinities, 0/0 , or numbers of a particular sign.<br />

<strong>The</strong> trait RationalQuantity takes seven static parameters; the first is a dimensional unit, and the others are booleans<br />

specifying whether an instance of the trait can possibly be −∞ , a finite rational less than zero, zero, a finite rational<br />

greater than zero, +∞ , or 0/0 . This allows the standard rational types to be represented as follows:<br />

type Q = RationalQuantitydimensionless,false,true,true,true,false,false<br />

type Q < = RationalQuantitydimensionless,false,true,false,false,false,false<br />

type Q ≤ = RationalQuantitydimensionless,false,true,true,false,false,false<br />

type Q ≥ = RationalQuantitydimensionless,false,false,true,true,false,false<br />

type Q > = RationalQuantitydimensionless,false,false,false,true,false,false<br />

type Q≠ = RationalQuantitydimensionless,false,true,false,true,false,false<br />

type Q ∗ = RationalQuantitydimensionless,true,true,true,true,true,false<br />

type Q ∗ < = RationalQuantitydimensionless,true,true,false,false,false,false<br />

type Q ∗ ≤ = RationalQuantitydimensionless,true,true,true,false,false,false<br />

type Q ∗ ≥ = RationalQuantitydimensionless,false,false,true,true,true,false<br />

type Q ∗ > = RationalQuantitydimensionless,false,false,false,true,true,false<br />

type Q ∗<br />

≠ = RationalQuantitydimensionless,true,true,false,true,true,false<br />

type Q # = RationalQuantitydimensionless,true,true,true,true,true,true<br />

type Q # < = RationalQuantitydimensionless,true,true,false,false,false,true<br />

type Q # ≤ = RationalQuantitydimensionless,true,true,true,false,false,true<br />

type Q # ≥ = RationalQuantitydimensionless,false,false,true,true,true,true<br />

type Q # > = RationalQuantitydimensionless,false,false,false,true,true,true<br />

type Q #<br />

≠ = RationalQuantitydimensionless,true,true,false,true,true,true<br />

Here is the detailed description of RationalQuantity, showing the details of the type calculations:<br />

262

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

Saved successfully!

Ooh no, something went wrong!