From: Magnus Holm Date: 2010-11-04T02:11:57+09:00 Subject: [ruby-core:33043] Re: [Ruby 1.9-Bug#4022][Open] Mistake in this cocient of logs followed by %1 --00163631030545c5b50494292321 Content-Type: text/plain; charset=UTF-8 That's just how floats work: >> Math.log(4913)/Math.log(17) == 3.0 => false >> "%.50f" % (Math.log(4913)/Math.log(17)) => "2.99999999999999955591079014993738383054733276367188" >> "%.50f" % 3.0 => "3.00000000000000000000000000000000000000000000000000" // Magnus Holm On Wed, Nov 3, 2010 at 17:52, Daniel Silberschmidt wrote: > Bug #4022: Mistake in this cocient of logs followed by %1 > http://redmine.ruby-lang.org/issues/show/4022 > > Author: Daniel Silberschmidt > Status: Open, Priority: Normal > Target version: 1.9.1 > ruby -v: 1.9.1 > > I get a wrong answer when I apply the following expression: > Math.log(4913)/Math.log(17) % 1 > This happens in ruby 1.9.1 and in ruby 1.8.7 > With other set of numbers the answers are correct > > irb(main):001:0> Math.log(4913)/Math.log(17) % 1 > => 1.0 > irb(main):002:0> Math.log(4913)/Math.log(17) > => 3.0 > irb(main):003:0> 3.0 % 1 > => 0.0 > irb(main):004:0> (Math.log(4913)/Math.log(17)) % 1 > => 1.0 > > > ---------------------------------------- > http://redmine.ruby-lang.org > > --00163631030545c5b50494292321 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable That's just how floats work:

>> Math.log(= 4913)/Math.log(17) =3D=3D 3.0
=3D> false
>> &q= uot;%.50f" % (Math.log(4913)/Math.log(17))
=3D> "2.9= 9999999999999955591079014993738383054733276367188"
>> "%.50f" % 3.0
=3D> "3.00000000000= 000000000000000000000000000000000000000"

// Magnus= Holm


On Wed, Nov 3, 2010 at 17:52, Daniel Sil= berschmidt <r= edmine@ruby-lang.org> wrote:
Bug #4022: Mistake in this cocient of logs followed by %1
http://redmine.ruby-lang.org/issues/show/4022

Author: Daniel Silberschmidt
Status: Open, Priority: Normal
Target version: 1.9.1
ruby -v: 1.9.1

I get a wrong answer when I apply the following expression: Math.log(4913)/= Math.log(17) % 1
This happens in ruby 1.9.1 and in ruby 1.8.7
With other set of numbers the answers are correct

irb(main):001:0> Math.log(4913)/Math.log(17) % 1
=3D> 1.0
irb(main):002:0> Math.log(4913)/Math.log(17)
=3D> 3.0
irb(main):003:0> 3.0 % 1
=3D> 0.0
irb(main):004:0> (Math.log(4913)/Math.log(17)) % 1
=3D> 1.0


----------------------------------------
http://redmine.r= uby-lang.org


--00163631030545c5b50494292321--