Orbital library

## orbital.math Interface Real

All Superinterfaces:
Arithmetic, java.lang.Comparable, Complex, Normed, Scalar
All Known Subinterfaces:
Integer, Rational

`public interface Realextends Complex, java.lang.Comparable`

Representation of a real number a∈R.

Of course, the machine prevents us from handling real numbers at all. This class provides rational decimal numbers up to machine precision, instead. In fact, the class `Real` is limited to decimals and does not even feel that any irrational numbers could possibly exist as well. But for we are patient humans, we wisely nod and satisfy ourselfes with decimal numbers.

Author:
André Platzer
`ValueFactory.valueOf(double)`, `ValueFactory.valueOf(float)`, `ValueFactory.valueOf(java.math.BigDecimal)`
Invariants:
(this is Comparable ∧ abnormal(¬Comparable)) ∨ abnormal(Comparable)
Stereotype:
data-type

Field Summary
`static Predicate` `hasType`
Checks whether the given number is in the set of reals and not a subset.
`static Predicate` `isa`
Checks whether the given number is in the set of reals.

Fields inherited from interface orbital.math.Arithmetic
`numerical`

Method Summary
` Real` `add(Real b)`

` int` `compareTo(java.lang.Object o)`
Compares this object with the specified object for order.
` Real` `divide(Real b)`

` double` `doubleValue()`
Returns the value of the specified real as a `double`.
` float` `floatValue()`
Returns the value of the specified real as a `float`.
` Real` `multiply(Real b)`

` Real` `power(Real b)`
Return ab.
` Real` `subtract(Real b)`

Methods inherited from interface orbital.math.Complex
`add, arg, conjugate, divide, equals, hashCode, im, isInfinite, isNaN, multiply, norm, power, re, subtract`

Methods inherited from interface orbital.math.Arithmetic
`add, divide, equals, inverse, isOne, isZero, minus, multiply, one, power, scale, subtract, toString, valueFactory, zero`

Field Detail

### isa

`static final Predicate isa`
Checks whether the given number is in the set of reals. return whether v is real (or rational or an integer).

### hasType

`static final Predicate hasType`
Checks whether the given number is in the set of reals and not a subset.

To be precise, for all numbers with machine precision can only be rational. Nevertheless, we model the difference between (machine precision) reals and explicit fractional numbers as `Rational`s with numerator and denominator.

return whether v∈R\Q is real, but not rational and thus irrational (for machine dimensions).

Method Detail

### compareTo

`int compareTo(java.lang.Object o)`
Compares this object with the specified object for order.

Specified by:
`compareTo` in interface `java.lang.Comparable`
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
`java.lang.ClassCastException` - if the specified object's type prevents it from being compared to this Object.
`Comparable.compareTo(Object)`
Preconditions:
this and o have comparable types
Postconditions:
∀e1,e2∈class (e1.compareTo((Object)e2)==0) ⇔ (e1.equals((Object)e2), i.e. compareTo is consistent with equals.

### floatValue

`float floatValue()`
Returns the value of the specified real as a `float`. This may involve rounding. Similar to the double-to-float narrowing primitive conversion as defined in The Java Language Specification: if this real has too great a magnitude to represent as a `float`, it will be converted to Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY as appropriate.

Returns:
the numeric value represented by this object after conversion to type `float`.

### doubleValue

`double doubleValue()`
Returns the value of the specified real as a `double`. This may involve rounding. Similar to the double-to-float narrowing primitive conversion as defined in The Java Language Specification: if this real has too great a magnitude to represent as a `double`, it will be converted to Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY as appropriate.

Returns:
the numeric value represented by this object after conversion to type `double`.

`Real add(Real b)`

### subtract

`Real subtract(Real b)`

### multiply

`Real multiply(Real b)`

### divide

`Real divide(Real b)`

### power

`Real power(Real b)`
Return ab.

Postconditions:
(b != 0 → RES instanceof Real)

Orbital library
1.3.0: 11 Apr 2009