@haxall/haxall
    Preparing search index...

    Class Float

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

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    type$: Type

    Methods

    • Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:

      this < that   =>  <0
      this == that => 0
      this > that => >0

      This method may also be accessed via the < <= <=> >= and > shortcut operators. If not overridden the default implementation compares the toStr representations. Also see docLang.

      Examples:

      3.compare(8)  =>  -1
      8.compare(3) => 1
      8.compare(8) => 0
      3 <=> 8 => -1 // shortcut for 3.compare(8)

      Parameters

      Returns number

    • Compare this object to the specified for equality. This method may be accessed via the == and != shortcut operators. If not overridden the default implementation compares for reference equality using the === operator. If this method is overridden, then hash() must also be overridden such that any two objects which return true for equals() must return the same value for hash(). This method must accept null and return false.

      Parameters

      Returns boolean

    • Return a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.

      Returns number

    • Return if this Obj is immutable and safe to share between threads:

      • an instance of a const class
      • the result of toImmutable on List, Map, or Buf
      • a Func object may or may not be immutable - see sys::Func.
      • other instances are assumed mutable and return false

      Returns boolean

    • Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:

      • if type is const, return this
      • if already an immutable List, Map, Buf, or Func return this
      • if a List, then attempt to perform a deep clone by calling toImmutable on all items
      • if a Map, then attempt to perform a deep clone by calling toImmutable on all values (keys are already immutable)
      • some Funcs can be made immutable - see sys::Func
      • if a Buf create immutable copy, see sys::Buf
      • any other object throws NotImmutableErr

      Returns Readonly<this>

    • Return a string representation of this object.

      Returns string

    • 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.

      Parameters

      Returns JsObj

    • Get the Type instance which represents this object's class. Also seeType.of or Pod.of.

      Returns Type

    • This method called whenever an it-block is applied to an object. The default implementation calls the function with this, and then returns this.

      Parameters

      • f: (arg0: this) => void

      Returns this

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

      Parameters

      • self: number

      Returns number

    • Return the arc cosine.

      Parameters

      • self: number

      Returns number

    • 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 lose 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

      Parameters

      • self: number
      • r: number
      • Optionaltolerance: number

      Returns boolean

    • Return the arc sine.

      Parameters

      • self: number

      Returns number

    • Return the arc tangent.

      Parameters

      • self: number

      Returns number

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

      Parameters

      • y: number
      • x: number

      Returns number

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

      Parameters

      • self: number

      Returns number

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

      Parameters

      • self: number

      Returns number

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

      Parameters

      • self: number

      Returns number

    • Clamp this float between the min and max. If its less than min then return min, if its greater than max return max, otherwise return this float itself.

      Parameters

      • self: number
      • min: number
      • max: number

      Returns number

    • Compare based on floating point value.

      NaN works as follows:

      • for the <=> operator NaN is always less than other values and equal to itself (so sort works as expected)
      • for all other comparison operators anything compared against NaN is false (normal Java semanatics)

      Examples:

      Float.nan <=> Float.nan  =>  0
      2f <=> Float.nan => 1
      Float.nan <=> 2f => -1
      2f < Float.nan => false
      Float.nan < 2f => false
      Float.nan <= Float.nan => false

      Parameters

      Returns number

    • Return the cosine of this angle in radians.

      Parameters

      • self: number

      Returns number

    • Return the hyperbolic cosine.

      Parameters

      • self: number

      Returns number

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

      Parameters

      • self: number

      Returns number

    • Default value is 0f.

      Returns number

    • Divide this by b. Shortcut is a/b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Divide this by b. Shortcut is a/b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Divide this by b. Shortcut is a/b.

      Parameters

      • self: number
      • b: number

      Returns number

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

      Returns number

    • Write 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.

      Parameters

      Returns void

    • Return true if same float value. Like Java, NaN != NaN. Also see compare.

      Parameters

      Returns boolean

    • Return e raised to this power.

      Parameters

      • self: number

      Returns number

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

      Parameters

      • self: number

      Returns number

    • 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.

      Parameters

      • s: string
      • Optionalchecked: boolean
      • ...args: unknown[]

      Returns Float

    • Return bits().

      Parameters

      • self: number

      Returns number

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

      Parameters

      • self: number

      Returns number

    • Return if this is Float.nan. Also see compare.

      Parameters

      • self: number

      Returns boolean

    • Return if this is negative zero value.

      Parameters

      • self: number

      Returns boolean

    • Get the current locale's decimal separator. For example in the the US this is a dot.

      Returns string

    • Get the current locale's separator for grouping thousands together. For example in the US this is a comma.

      Returns string

    • Get the current locale's minus sign used to represent a negative number.

      Returns string

    • Get the current locale's string representation for not-a-number.

      Returns string

    • Get the current locale's string representation for negative infinity.

      Returns string

    • Get the current locale's symbol for the percent sign.

      Returns string

    • Get the current locale's string representation for positive infinity.

      Returns string

    • Return natural logarithm of this number.

      Parameters

      • self: number

      Returns number

    • Return base 10 logarithm of this number.

      Parameters

      • self: number

      Returns number

    • 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.

      Parameters

      • bits: number

      Returns number

    • 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.

      Parameters

      • bits: number

      Returns number

    • Return the larger of this and the specified Float values.

      Parameters

      • self: number
      • that: number

      Returns number

    • Return the smaller of this and the specified Float values.

      Parameters

      • self: number
      • that: number

      Returns number

    • Subtract b from this. Shortcut is a-b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Subtract b from this. Shortcut is a-b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Subtract b from this. Shortcut is a-b.

      Parameters

      • self: number
      • b: number

      Returns number

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

      Parameters

      • self: number
      • b: number

      Returns number

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

      Parameters

      • self: number
      • b: number

      Returns number

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

      Parameters

      • self: number
      • b: number

      Returns number

    • Multiply this with b. Shortcut is a*b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Multiply this with b. Shortcut is a*b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Multiply this with b. Shortcut is a*b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Float value for Not-A-Number.

      Returns number

    • Negative of this. Shortcut is -a.

      Parameters

      • self: number

      Returns number

    • Float value for negative infinity.

      Returns number

    • If this value is negative zero then return normalized zero, otherwise return this value.

      Parameters

      • self: number

      Returns number

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

      Returns number

    • Add this with b. Shortcut is a+b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Add this with b. Shortcut is a+b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Add this with b. Shortcut is a+b.

      Parameters

      • self: number
      • b: number

      Returns number

    • Float value for positive infinity.

      Returns number

    • Return this value raised to the specified power.

      Parameters

      • self: number
      • pow: number

      Returns number

    • Generate a random float between 0.0 inclusive and 1.0 exclusive. Also see Int.random, Range.random, List.random, and util::Random.

      Returns number

    • Returns the nearest whole number to this number.

      Parameters

      • self: number

      Returns number

    • Return sine of this angle in radians.

      Parameters

      • self: number

      Returns number

    • Return hyperbolic sine.

      Parameters

      • self: number

      Returns number

    • Return square root of this value.

      Parameters

      • self: number

      Returns number

    • Return tangent of this angle in radians.

      Parameters

      • self: number

      Returns number

    • Return hyperbolic tangent.

      Parameters

      • self: number

      Returns number

    • Get this Float as a Fantom code literal.

      Parameters

      • self: number

      Returns string

    • Convert this number to a Decimal.

      Parameters

      • self: number

      Returns number

    • Convert this angle in radians to an angle in degrees.

      Parameters

      • self: number

      Returns number

    • Convert this number to a Float.

      Parameters

      • self: number

      Returns number

    • Convert this number to an Int.

      Parameters

      • self: number

      Returns number

    • Format this floating point number for the current locale. If pattern is null, then the locale's default pattern is used. Also see Num.localeDecimal, Num.localeGrouping, etc.

      The pattern format:

      #   optional digit
      0 required digit
      . decimal point
      , grouping separator (only last one before decimal matters)

      Examples:

      12345.786f.toLocale("#,###.0")  =>  12,345.8
      7.1234f.toLocale("#.000") => 7.123
      0.1234f.toLocale("#.000") => .123
      0.1234f.toLocale("0.00") => 0.12
      70.12f.toLocale("0.0000") => 70.1200

      Parameters

      • self: number
      • Optionalpattern: string
      • Optionallocale: Locale

      Returns string

    • Convert this angle in degrees to an angle in radians.

      Parameters

      • self: number

      Returns number

    • 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".

      Parameters

      • self: number

      Returns string