19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

25.1.26 floor(self): Z<br />

25.1.27 opr ⌊self⌋: Z<br />

25.1.28 ceiling(self): Z<br />

25.1.29 opr ⌈self⌉: Z<br />

25.1.30 round(self): Z<br />

25.1.31 truncate(self): Z<br />

<strong>The</strong> method floor , likewise the enclosing operator ⌊. . .⌋ , returns the largest integer that is not greater than this rational<br />

number.<br />

<strong>The</strong> method ceiling , likewise the enclosing operator ⌈. . .⌉ , returns the smallest integer that is not less than this rational<br />

number.<br />

<strong>The</strong> method round returns the integer that is closest to this rational number, but if this rational number is exactly<br />

halfway between two consecutive integers, then round returns whichever of the two integers is even.<br />

<strong>The</strong> method truncate returns the ceiling of this rational number if it is negative, and otherwise returns the floor of this<br />

rational number. (This has the effect of taking the floor of the magnitude, also called “rounding toward zero.”)<br />

For types Q ∗ and Q # , all of these methods simply return the argument if it is +∞ , −∞ , or 0/0 .<br />

opr ⌊self ⌋: N<br />

opr ⌈self ⌉: N<br />

opr ⌊self ⌋: N<br />

opr ⌈self ⌉: N<br />

<strong>The</strong> hyperfloor operation ⌊x ⌋ computes 2 ( ⌊log 2 x⌋) and returns the result as a natural number. If the argument is<br />

equal to 0 , the result is 0 . If the argument is negative, an InvalidArgumentException is thrown.<br />

<strong>The</strong> hyperceiling operation ⌈x ⌉ computes 2 ( ⌈log 2 x⌉) and returns the result as a natural number. If the argument is<br />

equal to 0 , the result is 0 . If the argument is negative, an InvalidArgumentException is thrown.<br />

<strong>The</strong> hyperhyperfloor operation ⌊x ⌋ computes 2 ( ⌊log 2 x ⌋) and returns the result as a natural number. If the argument<br />

is equal to 0 or 1 , the result is the same as the argument. If the argument is negative, an InvalidArgumentException<br />

is thrown.<br />

<strong>The</strong> hyperhyperceiling operation ⌈x ⌉ computes 2 ( ⌈log 2 x ⌉) and returns the result as a natural number. If the argument<br />

is equal to 0 or 1 , the result is the same as the argument. If the argument is negative, an InvalidArgumentException<br />

is thrown.<br />

25.1.32 realpart(self): Q<br />

<strong>The</strong> method realpart for a rational number simply returns its argument.<br />

25.1.33 imagpart(self): Q<br />

<strong>The</strong> method imagpart for a rational number simply returns zero.<br />

199

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

Saved successfully!

Ooh no, something went wrong!