Return absolute value of this number.
Return if this number is approximately equal to that - see sys::Float.approx
Optional
tolerance: numberClamp this number between the min and max. If its less than min then return min, if its greater than max return max, otherwise return this number itself. The min and max must have matching units or be unitless. The result is always in the same unit as this instance.
Decrement this number. Shortcut is --a.
Equality is based on val and unit. NaN is equal to itself (like Float.compare, but unlike Float.equals)
Hash is based on val
Increment this number. Shortcut is ++a.
Does this number have a time unit which can be converted to a Fantom Duration instance.
Is this number a whole integer without a fractional part
Is the floating value NaN.
Is this a negative number
Return if this number if pos/neg infinity or NaN
Get the ASCII lower case version of this number as a Unicode point.
Negate this number. Shortcut is -a.
Trio/zinc code representation, same as toStr
Get the scalar value as an Float
Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:
Get the scalar value as an Int
Format the number using given pattern which is an superset of sys::Float.toLocale:
# optional digit
0 required digit
. decimal point
, grouping separator (only last one before decimal matters)
U position of unit (default to suffix)
pos;neg separate negative format (must specify U position)
When using the pos;neg
pattern, the "U" position must be
specified in both pos and neg patterns, otherwise the unit
is omitted. Note that the negative pattern always uses
mimics the positive pattern for the actual digit formatting
(#, 0, decimal, and grouping).
The special "B" pattern is used to format bytes; see sys::Int.toLocale.
If pattern is null, the following rules are used:
Examples:
Number Pattern Result Notes
------ ------- ------- ------
12.34 "#.####" 12.34 Optional fractional digits
12.34 "#.0000" 12.3400 Required fractional digits
12.34$ null $12.34 Haystack locale default
12$ "U 0.00" $ 12.00 Explicit unit placement
-12$ "U0.##;(U#)" ($12) Alternative negative format
45% "+0.0U;-0.0U" +45% Use leading positive sign
Optional
pattern: stringString representation
Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:
a->x a.trap("x", null)
a->x() a.trap("x", null)
a->x = b a.trap("x", [b])
a->x(b) a.trap("x", [b])
a->x(b, c) a.trap("x", [b, c])
The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.
Get unit associated with this number or null.
Get the ASCII upper case version of this number as a Unicode point.
This method called whenever an it-block is applied to an
object. The default implementation calls the function with this
,
and then returns this
.
Static
defDefault value is zero with no unit
Static
echoWrite x.toStr
to standard output followed by newline. If x
is null then print "null". If no argument is provided then
print an empty line.
Optional
x: JsObjStatic
fromParse from a string according to zinc syntax
Optional
checked: booleanStatic
makeStatic
makeStatic
makeStatic
makeStatic
nanConstant for not-a-number
Static
negConstant for negative infinity
Static
negConstant for -1 with no unit
Static
oneConstant for 1 with no unit
Static
posConstant for positive infinity
Static
tenConstant for 10 with no unit
Static
zeroConstant for 0 with no unit
Number represents a numeric value and an optional Unit.