Hello
Class Numeric doku says:
div(numeric) → integer
Uses |/| to perform division, then converts the result to an integer.
numeric> does not define the |/| operator; this is left to subclasses.
BUT: 4.0 / 3 is float, not converted to numeric
What is correct, what should it be?
Opti
irb(main):001:0> Float.ancestors
=> [Float, Numeric, Comparable, Object, Kernel, BasicObject]
irb(main):002:0> 0.3.is_a? Numeric
=> true
Hope this helps,
Mike
···
On Jan 31, 2017, at 8:11 AM, Die Optimisten <inform@die-optimisten.net> wrote:
Hello
Class Numeric doku says:
div(numeric) → integer
Uses / to perform division, then converts the result to an integer. numeric does not define the / operator; this is left to subclasses.
BUT: 4.0 / 3 is float, not converted to numeric
What is correct, what should it be?
Opti
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
--
Mike Stok <mike@stok.ca>
http://www.stok.ca/~mike/
The "`Stok' disclaimers" apply.
Hi!
I know, its just the sentence "then converts the result to an integer" (in difference to the "/" operator!)
Opti
···
On 2017-01-31 15:53, Mike Stok wrote:
irb(main):001:0> Float.ancestors
=> [Float, Numeric, Comparable, Object, Kernel, BasicObject]
irb(main):002:0> 0.3.is_a? Numeric
=> true
Hope this helps,
Mike
On Jan 31, 2017, at 8:11 AM, Die Optimisten >> <inform@die-optimisten.net <mailto:inform@die-optimisten.net>> wrote:
Hello
Class Numeric doku says:
div(numeric) → integer
Uses |/| to perform division, then converts the result to an integer. >numeric> does not define the |/| operator; this is left to subclasses.
BUT: 4.0 / 3 is float, not converted to numeric
What is correct, what should it be?
Opti
Sorry for my misunderstanding 
I think it’s just being explicit about the difference between div and / :
irb(main):001:0> 40.0.div(7)
=> 5
irb(main):002:0> 40.0.div(7).class
=> Integer
irb(main):003:0> 40.0 / 7
=> 5.714285714285714
irb(main):004:0> (40.0 / 7).class
=> Float
Hope this helps,
Mike
···
On Jan 31, 2017, at 10:30 AM, Die Optimisten <inform@die-optimisten.net> wrote:
Hi!
I know, its just the sentence "then converts the result to an integer" (in difference to the "/" operator!)
Opti
On 2017-01-31 15:53, Mike Stok wrote:
irb(main):001:0> Float.ancestors
=> [Float, Numeric, Comparable, Object, Kernel, BasicObject]
irb(main):002:0> 0.3.is_a? Numeric
=> true
Hope this helps,
Mike
On Jan 31, 2017, at 8:11 AM, Die Optimisten <inform@die-optimisten.net <mailto:inform@die-optimisten.net>> wrote:
Hello
Class Numeric doku says:
div(numeric) → integer
Uses / to perform division, then converts the result to an integer. numeric does not define the / operator; this is left to subclasses.
BUT: 4.0 / 3 is float, not converted to numeric
What is correct, what should it be?
Opti
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
--
Mike Stok <mike@stok.ca>
http://www.stok.ca/~mike/
The "`Stok' disclaimers" apply.
Hi
my mistake - it is as expected.
(seems I mixed up / with div )
Opti
···
On 2017-01-31 16:35, Mike Stok wrote:
Sorry for my misunderstanding 
I think it’s just being explicit about the difference between div and / :
irb(main):001:0> 40.0.div(7)
=> 5
irb(main):002:0> 40.0.div(7).class
=> Integer
irb(main):003:0> 40.0 / 7
=> 5.714285714285714
irb(main):004:0> (40.0 / 7).class
=> Float
Hope this helps,
Mike
On Jan 31, 2017, at 10:30 AM, Die Optimisten >> <inform@die-optimisten.net <mailto:inform@die-optimisten.net>> wrote:
Hi!
I know, its just the sentence "then converts the result to an integer" (in difference to the "/" operator!)
Opti
On 2017-01-31 15:53, Mike Stok wrote:
irb(main):001:0> Float.ancestors
=> [Float, Numeric, Comparable, Object, Kernel, BasicObject]
irb(main):002:0> 0.3.is_a? Numeric
=> true
Hope this helps,
Mike
On Jan 31, 2017, at 8:11 AM, Die Optimisten >>>> <inform@die-optimisten.net <mailto:inform@die-optimisten.net>> wrote:
Hello
Class Numeric doku says:
div(numeric) → integer
Uses |/| to perform division, then converts the result to an integer. |numeric| does not define the |/| operator; this is left to subclasses.
BUT: 4.0 / 3 is float, not converted to numeric
What is correct, what should it be?
Opti