Class: Integer
- Inherits:
-
Numeric
- Object
- Numeric
- Integer
- Defined in:
- lib/bigdecimal/util.rb,
sig/big_decimal.rbs,
sig/big_decimal_util.rbs
Instance Method Summary collapse
-
#* ⇒ Object
Performs multiplication:.
-
#+ ⇒ Object
Performs addition:.
-
#- ⇒ Object
Performs subtraction:.
-
#/ ⇒ Object
Performs division; for integer `numeric`, truncates the result to an integer:.
-
#to_d ⇒ BigDecimal
Returns the value of `int` as a BigDecimal.
Instance Method Details
#*(arg0) ⇒ BigDecimal #* ⇒ void
Performs multiplication:
4 * 2 # => 8
4 * -2 # => -8
-4 * 2 # => -8
4 * 2.0 # => 8.0
4 * Rational(1, 3) # => (4/3)
4 * Complex(2, 0) # => (8+0i)
1280 1281 |
# File 'sig/big_decimal.rbs', line 1280 def *: (BigDecimal) -> BigDecimal | ... |
#+(arg0) ⇒ BigDecimal #+ ⇒ void
Performs addition:
2 + 2 # => 4
-2 + 2 # => 0
-2 + -2 # => -4
2 + 2.0 # => 4.0
2 + Rational(2, 1) # => (4/1)
2 + Complex(2, 0) # => (4+0i)
1296 1297 |
# File 'sig/big_decimal.rbs', line 1296 def +: (BigDecimal) -> BigDecimal | ... |
#-(arg0) ⇒ BigDecimal #- ⇒ void
Performs subtraction:
4 - 2 # => 2
-4 - 2 # => -6
-4 - -2 # => -2
4 - 2.0 # => 2.0
4 - Rational(2, 1) # => (2/1)
4 - Complex(2, 0) # => (2+0i)
1312 1313 |
# File 'sig/big_decimal.rbs', line 1312 def -: (BigDecimal) -> BigDecimal | ... |
#/(arg0) ⇒ BigDecimal #/ ⇒ void
Performs division; for integer numeric, truncates the result to an integer:
4 / 3 # => 1
4 / -3 # => -2
-4 / 3 # => -2
-4 / -3 # => 1
For other +numeric+, returns non-integer result:
4 / 3.0 # => 1.3333333333333333
4 / Rational(3, 1) # => (4/3)
4 / Complex(3, 0) # => ((4/3)+0i)
1264 1265 |
# File 'sig/big_decimal.rbs', line 1264 def /: (BigDecimal) -> BigDecimal | ... |
#to_d ⇒ BigDecimal
Returns the value of int as a BigDecimal.
require 'bigdecimal'
require 'bigdecimal/util'
42.to_d # => 0.42e2
See also Kernel.BigDecimal.
23 24 25 |
# File 'lib/bigdecimal/util.rb', line 23 def to_d BigDecimal(self) end |