# Fraction

Fraction inherits from Number and defines instance variables numerator, denominator. It has no subclasses.

Fractions are rational numbers.
The numerator and denominator of a Fraction are assumed to be Integers---and are therefore affected by the same restrictions imposed on Integers (see the comment of Integer for explanation).

## Methods defined in Fraction:

### Methods for accessing:

- denominator
- numerator

### Methods for arithmetic:

- - number
- * number
- / number
- // number
- + number

### Methods for comparing:

- < number
- = number
- hash

### Methods for converting:

- asDouble
- asFraction
- asInteger

### Methods for double dispatching:

- addToFraction: fraction
- addToInteger: integer
- coerce: number
- divideIntoFraction: fraction
- divideIntoInteger: integer
- equalToFraction: fraction
- equalToInteger: integer
  Always false, since Fractions are assumed to be non-integer rationals.
- generality
- greaterThanFraction: fraction
- greaterThanInteger: integer
- multiplyByFraction: fraction
- multiplyByInteger: integer
- subtractFromFraction: fraction
- subtractFromInteger: integer

### Methods for initialization:

- numerator: n denominator: d

### Methods for math functions:

- negated
- reciprocal
- truncated

### Methods for predicates:

- isZero

### Methods for printing:

- printOn: stream

Pocket Smalltalk Documentation