number/real#
Type Aliases#
Real#
Real =
Rational|number
Defined in: number/real.ts:19
An exact value (int or Fraction) or a float.
Functions#
addReal()#
addReal(
left,right):Real
Defined in: number/real.ts:129
left + right: exact when both are exact, otherwise a float.
Parameters#
left#
right#
Returns#
compareReal()#
compareReal(
left,right):-1|0|1
Defined in: number/real.ts:142
-1, 0 or 1; a float and an exact value compare exactly.
Parameters#
left#
right#
Returns#
-1 | 0 | 1
exactCoordinate()#
exactCoordinate(
value,unit,numberType):Coordinate|undefined
Defined in: number/real.ts:153
A value as a coordinate on an axis, only when the axis’s number type holds
it exactly (and within int64); otherwise undefined.
Parameters#
value#
unit#
TimeUnit
numberType#
NumberType
Returns#
Coordinate | undefined
fromFloat()#
fromFloat(
value):Rational
Defined in: number/real.ts:76
The exact value of a double, as Python’s Fraction(float). For arithmetic
that must be exact on a float’s value (a page transform); a coordinate is
never re-expressed through it.
Parameters#
value#
number
Returns#
realOf()#
realOf(
coordinate):Real
Defined in: number/real.ts:122
A coordinate’s value as Python holds it.
Parameters#
coordinate#
Returns#
roundFloat()#
roundFloat(
x,places):number
Defined in: number/real.ts:108
x rounded to places decimal places as Python’s round(x, places):
the exact value of the double times 10^places, rounded to an integer
half to even, and the double nearest to that integer over 10^places.
The sign of a zero result is x’s; an infinity or NaN is returned as
given.
Parameters#
x#
number
places#
number
Returns#
number
Throws#
if places is not a safe integer.
subtractReal()#
subtractReal(
left,right):Real
Defined in: number/real.ts:137
left − right, as left + (−right): exact when both are exact, otherwise a float.
Parameters#
left#
right#
Returns#
toFloat()#
toFloat(
value):number
Defined in: number/real.ts:47
The double nearest to an exact value, ties to even, as Python’s float(Fraction).
Parameters#
value#
Returns#
number
toRational()#
toRational(
value):Rational
Defined in: number/real.ts:94
The exact value of a coordinate value or a Real: a Fraction as it is, an
int as the Fraction n/1, a float by its exact binary value (fromFloat).