logo

const final class

sys::Float

sys::Obj
  sys::Num
    sys::Float

Float is used to represent a 64-bit floating point number.

Slots

abs

Float abs()

Return the absolute value of this float. If this value is positive then return this, otherwise return the negation.

Source

acos

Float acos()

Return the arc cosine.

Source

approx

Bool approx(Float r, Float tolerance := null)

Return if this Float is approximately equal to the given Float by the specified tolerance. If tolerance is null, then it is computed using the magnitude of the two Floats. It is useful for comparing Floats since often they loose a bit of precision during manipulation. This method is equivalent to:

if (tolerance == null) tolerance = min(abs(this/1e6), abs(r/1e6))
(this - r).abs < tolerance

Source

asin

Float asin()

Return the arc sine.

Source

atan

Float atan()

Return the arc tangent.

Source

atan2

static Float atan2(Float y, Float x)

Converts rectangular coordinates (x, y) to polar (r, theta).

Source

bits

Int bits()

Return 64-bit representation according IEEE 754 floating-point double format bit layout. This method is paired with Float.makeBits.

Source

bits32

Int bits32()

Return 32-bit representation according IEEE 754 floating-point single format bit layout. This method is paired with Float.makeBits32.

Source

ceil

Float ceil()

Returns the smallest whole number greater than or equal to this number.

Source

compare

override Int compare(Obj obj)

Compare based on floating point value.

Source

cos

Float cos()

Return the cosine of this angle in radians.

Source

cosh

Float cosh()

Return the hyperbolic cosine.

Source

decrement

Float decrement()

Decrement by one. Shortcut is --a or a--.

Source

div

Float div(Float b)

Divide this by b. Shortcut is a/b.

Source

e

static Float e

Float value for e which is the base of natural logarithms.

Source

equals

override Bool equals(Obj obj)

Return true if same float value. Unlike Java, NaN equals NaN.

Source

exp

Float exp()

Return e raised to this power.

Source

floor

Float floor()

Returns the largest whole number less than or equal to this number.

Source

fromStr

static Float fromStr(Str s, Bool checked := true)

Parse a Str into a Float. Representations for infinity and not-a-number are "-INF", "INF", "NaN". This string format matches the lexical representation of Section 3.2.5 of XML Schema Part 2. If invalid format and checked is false return null, otherwise throw ParseErr.

TODO: need spec - follow XML Schema literal definition

Source

hash

override Int hash()

Return bits().

Source

increment

Float increment()

Increment by one. Shortcut is ++a or a++.

Source

log

Float log()

Return natural logarithm of this number.

Source

log10

Float log10()

Return base 10 logarithm of this number.

Source

makeBits

static Float makeBits(Int bits)

Make a Float for the specified 64-bit representation according IEEE 754 floating-point double format bit layout. This method is paired with Float.bits.

Source

makeBits32

static Float makeBits32(Int bits)

Make a Float for the specified 32-bit representation according IEEE 754 floating-point single format bit layout. This method is paired with Float.bits32.

Source

max

Float max(Float that)

Return the larger of this and the specified Float values.

Source

min

Float min(Float that)

Return the smaller of this and the specified Float values.

Source

minus

Float minus(Float b)

Subtract b from this. Shortcut is a-b.

Source

mod

Float mod(Float b)

Return remainder of this divided by b. Shortcut is a%b.

Source

mult

Float mult(Float b)

Multiply this with b. Shortcut is a*b.

Source

nan

static Float nan

Float value for Not-A-Number.

Source

negInf

static Float negInf

Float value for negative infinity.

Source

negate

Float negate()

Negative of this. Shortcut is -a.

Source

pi

static Float pi

Float value for pi which is the ratio of the circumference of a circle to its diameter.

Source

plus

Float plus(Float b)

Add this with b. Shortcut is a+b.

Source

posInf

static Float posInf

Float value for positive infinity.

Source

pow

Float pow(Float pow)

Return this value raised to the specified power.

Source

round

Float round()

Returns the nearest whole number to this number.

Source

sin

Float sin()

Return sine of this angle in radians.

Source

sinh

Float sinh()

Return hyperbolic sine.

Source

sqrt

Float sqrt()

Return square root of this value.

Source

tan

Float tan()

Return tangent of this angle in radians.

Source

tanh

Float tanh()

Return hyperbolic tangent.

Source

toDecimal

override Decimal toDecimal()

Convert this Float to a Decimal.

Source

toDegrees

Float toDegrees()

Convert this angle in radians to an angle in degrees.

Source

toFloat

override Float toFloat()

Return this.

Source

toInt

override Int toInt()

Convert this Float to an Int.

Source

toRadians

Float toRadians()

Convert this angle in degrees to an angle in radians.

Source

toStr

override Str toStr()

Get string representation according to the lexical representation defined by Section 3.2.5 of XML Schema Part 2. Representations for infinity and not-a-number are "-INF", "INF", "NaN".

Source