Class: Integer
- Inherits:
-
Numeric
show all
- Defined in:
- opal/opal/corelib/number.rb,
opal/opal/corelib/marshal/write_buffer.rb
Constant Summary
collapse
- MAX =
`Math.pow(2, 30) - 1`
- MIN =
`-Math.pow(2, 30)`
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Numeric
#%, #+@, #-@, #<=>, #__coerced__, #abs, #abs2, #angle, #ceil, #clone, #coerce, #conj, #denominator, #div, #divmod, #dup, #fdiv, #finite?, #floor, #i, #imag, #infinite?, #integer?, #negative?, #nonzero?, #numerator, #polar, #positive?, #quo, #real, #real?, #rect, #round, #to_c, #to_int, #truncate, #zero?
Methods included from Comparable
#<, #<=, #==, #>, #>=, #between?, #clamp
Class Method Details
.===(other) ⇒ Object
1021
1022
1023
1024
1025
1026
1027
1028
1029
|
# File 'opal/opal/corelib/number.rb', line 1021
def ===(other)
%x{
if (!other.$$is_number) {
return false;
}
return (other % 1) === 0;
}
end
|
1015
1016
1017
|
# File 'opal/opal/corelib/number.rb', line 1015
def allocate
raise TypeError, "allocator undefined for #{name}"
end
|
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
|
# File 'opal/opal/corelib/number.rb', line 1031
def sqrt(n)
n = Opal.coerce_to!(n, Integer, :to_int)
%x{
if (n < 0) {
#{raise Math::DomainError, 'Numerical argument is out of domain - "isqrt"'}
}
return parseInt(Math.sqrt(n), 10);
}
end
|
Instance Method Details
#__marshal__(buffer) ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'opal/opal/corelib/marshal/write_buffer.rb', line 18
def __marshal__(buffer)
if self >= -0x40000000 && self < 0x40000000
buffer.append('i')
buffer.write_fixnum(self)
else
buffer.append('l')
buffer.write_bignum(self)
end
end
|