const classcamAxonPlugin::Number
sys::Obj camAxonPlugin::Number
@
Js@
Serializable { simple=true }
Number represents a numeric value and an optional Unit.
- abs
Number abs()
Return absolute value of this number.
- approx
Bool approx(Number that, Float? tolerance := null)
Return if this number is approximately equal to that - see sys::Float.approx
- compare
virtual override Int compare(Obj that)
Compare is based on val. Throw UnitErr is this and b have incompatible units.
- decrement
Decrement this number. Shortcut is --a.
- div
@
Operator
Number div(Number b)Divide this by b. Shortcut is a/b. The resulting unit is derived from the quotient of this and b. Throw UnitErr if a/b does not match a unit in the unit database.
- equals
virtual override Bool equals(Obj? that)
Equality is based on val and unit. NaN is equal to itself (like Float.compare, but unlike Float.equals)
- fromStr
static new fromStr(Str s, Bool checked := true)
Parse from a string according to zinc syntax
- hash
virtual override Int hash()
Hash is based on val
- increment
Increment this number. Shortcut is ++a.
- isInt
Bool isInt()
Is this number a whole integer without a fractional part
- isNaN
Bool isNaN()
Is the floating value NaN.
- isSpecial
Bool isSpecial()
Return if this number if pos/neg infinity or NaN
- lower
Number lower()
Get the ASCII lower case version of this number as a Unicode point.
- make
new make(Float val, Unit? unit := null)
Construct from scalar value and optional unit.
- makeDuration
new makeDuration(Duration dur, Unit? unit := @hr)
Construct from a duration, standardize unit is hours If unit is null, then a best attempt is made based on magnitude.
- makeInt
new makeInt(Int val, Unit? unit := null)
Construct from scalar integer and optional unit.
- makeNum
static Number makeNum(Num val, Unit? unit := null)
Construct from scalar Int, Float, or Decimal and optional unit.
- max
Return max value
- min
Return min value
- minus
@
Operator
Number minus(Number b)Subtract b from this. Shortcut is a-b. The b.unit must match this.unit.
- mod
@
Operator
Number mod(Number b)Return remainder of this divided by b. Shortcut is a%b. The unit of b must be null.
- mult
@
Operator
Number mult(Number b)Multiple this and b. Shortcut is a*b. The resulting unit is derived from the product of this and b. Throw UnitErr if a*b does not match a unit in the unit database.
- nan
const static Number nan := Number.<ctor>(Float.nan)
- negInf
const static Number negInf := Number.<ctor>(Float.negInf)
- negOne
const static Number negOne := Number.<ctor>(-1.0)
- negate
Negate this number. Shortcut is -a.
- one
const static Number one := Number.<ctor>(1.0)
- plus
@
Operator
Number plus(Number b)Add this with b. Shortcut is a+b. Throw UnitErr is this and b have incompatible units.
- posInf
const static Number posInf := Number.<ctor>(Float.posInf)
- ten
const static Number ten := Number.<ctor>(10.0)
- toCode
Str toCode()
Trio/zinc code representation, same as toStr
- toDuration
Duration? toDuration(Bool checked := true)
Get this number as a Fantom Duration instance
- toFloat
Float toFloat()
Get the scalar value as an Float
- toInt
Int toInt()
Get the scalar value as an Int
- toLocale
Str toLocale(Str? pattern := null)
Format the number according to sys::Float.toLocale pattern language. Unit symbol is always added as suffix if available.
- toStr
virtual override Str toStr()
String representation
- unit
Unit? unit()
Get unit associated with this number or null.
- upper
Number upper()
Get the ASCII upper case version of this number as a Unicode point.
- zero
const static Number zero := Number.<ctor>(0.0)