Class: RubyJS.Float

Defined in: lib/corelib/float.coffee
Inherits: RubyJS.Numeric

Constant Summary

DIG =
15
EPSILON =
0.0000000000000002220446049250313080847263336181640625
MANT_DIG =
53
MAX_EXP =
1024
MAX =
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368
MANT_DIG =
53
MIN =
2.225073858507201383090232717332404064219215980462331830553327416887204434813918195854283159012511020564067339731035811005152434161553460108856012385377718821130777993532002330479610147442583636071921565046942503734208375250806650616658158948720491179968591639648500635908770118304874799780887753749949451580451605050915399856582470818645113537935804992115981085766051992433352114352390148795699609591288891602992641511063466313393663477586513029371762047325631781485664350872122828637642044846811407613911477062801689853244110024161447421618567166150540154285084716752901903161322778896729707373123334086988983175067838846926092773977972858659654941091369095406136467568702398678315290680984617210924625396728515625e-308
RADIX =
2

Class Method Summary

Instance Method Summary

Inherited Method Summary

Methods inherited from RubyJS.Numeric

.isNumeric, .try_convert, .new, .typecast, '-instance'>#'<=>', #abs, #abs2, #ceil, #coerce, #div, #divmod, #eql, #inspect, #fdiv, #floor, #magnitude, #modulo, #nonzero, #quo, #rect, #remainder, #round, #step, #truncate, #uminus, #zero

Methods inherited from RubyJS.Object

.include, .__add_default_aliases__, #send, #respond_to, #to_enum, #tap

Class Method Details

+ (void) new(f)

rubyism

+ (void) isFloat(obj)

Constructor Details

- (void) constructor(__native__)

Instance Method Details

'-instance'> - (void) '<=>'(other)

- (void) '=='(other)

- (void) '+'(other)

- (void) '-'(other)

- (void) '*'(other)

- (void) '/'(other)

- (void) '**'(other)

- (void) '%'(other)

- (R.Float) arg()

Returns 0 if the value is positive, pi otherwise.

@alias #angle, #phase

Returns:

  • R.Float

- (R.Fixnum) ceil()

Returns the smallest Integer greater than or equal to flt.

Examples:


 R( 1.2).ceil()      #=> 2
 R( 2.0).ceil()      #=> 2
 R(-1.2).ceil()      #=> -1
 R(-2.0).ceil()      #=> -2

Returns:

  • R.Fixnum

- (void) inspect()

- (void) dup()

- (Boolean) eql(other)

Returns true only if obj is a Float with the same value as flt. Contrast this with Float#==, which performs type conversions.

Examples:


  new R.Float(1.0).eql(1)   #=> false

Returns:

  • Boolean

- (Boolean) finite()

Returns true if flt is a valid IEEE floating point number (it is not infinite, and nan? is false).

Returns:

  • Boolean

- (Boolean) infinite()

Returns nil, -1, or +1 depending on whether flt is finite, -infinity, or +infinity.

Examples:


  new R.Float(0.0).infinite()        #=> nil
  new R.Float(-1.0/0.0).infinite()   #=> -1
  new R.Float(+1.0/0.0).infinite()   #=> 1

Returns:

  • Boolean

- (Boolean) nan()

Returns true if flt is an invalid IEEE floating point number.

Examples:


  a = new R.Float(-1.0)      #=> -1.0
  a.nan()                    #=> false
  a = new R.Float(0.0/0.0)   #=> NaN
  a.nan()                    #=> true

Returns:

  • Boolean

- (void) to_f()

As flt is already a float, returns self.

- (R.Fixnum) to_i()

Returns flt truncated to an Integer.

Returns:

  • R.Fixnum

- (R.Fixnum) floor()

Returns the largest integer less than or equal to flt.

Examples:


  new R.Float(1.2).floor()    #=> 1
  new R.Float(2.0).floor()    #=> 2
  new R.Float(-1.2).floor()   #=> -2
  new R.Float(-2.0).floor()   #=> -2

Returns:

  • R.Fixnum

- (R.Float) quo(other)

Returns float / numeric.

Returns:

  • R.Float

- (R.Fixnum, R.Float) round(n = 0)

Rounds flt to a given precision in decimal digits (default 0 digits). Precision may be negative. Returns a floating point number when ndigits is more than zero.

Examples:


  R(1.4).round()      #=> 1
  R(1.5).round()      #=> 2
  R(1.6).round()      #=> 2
  R(-1.5).round()     #=> -2
  R(1.234567).round(2)  #=> 1.23
  R(1.234567).round(3)  #=> 1.235
  R(1.234567).round(4)  #=> 1.2346
  R(1.234567).round(5)  #=> 1.23457
  R(34567.89).round(-5) #=> 0
  R(34567.89).round(-4) #=> 30000
  R(34567.89).round(-3) #=> 35000
  R(34567.89).round(-2) #=> 34600
  R(34567.89).round(-1) #=> 34570
  R(34567.89).round(0)  #=> 34568
  R(34567.89).round(1)  #=> 34567.9
  R(34567.89).round(2)  #=> 34567.89
  R(34567.89).round(3)  #=> 34567.89

Returns:

  • R.Fixnum, R.Float

- (R.String) to_s()

Returns a string containing a representation of self. As well as a fixed or exponential form of the number, the call may return “NaN”, “Infinity”, and “-Infinity”.

Returns:

  • R.String

- (String) toString()

Returns:

  • String

- (String) valueOf()

Returns:

  • String

- (String) to_native()

Returns:

  • String