Fix Float#to_d behaviour #323

Closed
wants to merge 1 commit into
from

Conversation

3 participants
@vipulnsward

Currently

9.05.to_d.to_s('F') => "9.050000000000001"

which adds the extra '1'
This patch tries to fix this behaviour and associated tests

Currently
9.05.to_d.to_s('F') => "9.050000000000001"

which adds the extra '1'
This patch tries to fix this behaviour and associated tests
@vipulnsward

This comment has been minimized.

Show comment Hide comment
@vipulnsward

vipulnsward Jun 4, 2013

cc @mrkn

@evanphx evanphx closed this in 1699396 Jun 4, 2013

@judofyr

This comment has been minimized.

Show comment Hide comment
@judofyr

judofyr Jun 4, 2013

Member

Anyone knows why it was Float::DIG+1 earlier?

Member

judofyr commented Jun 4, 2013

Anyone knows why it was Float::DIG+1 earlier?

@zzak

This comment has been minimized.

Show comment Hide comment
@zzak

zzak Jun 4, 2013

Member

@judofyr Here's the commit: 079fb8d

Member

zzak commented Jun 4, 2013

@judofyr Here's the commit: 079fb8d

tenderlove pushed a commit to tenderlove/ruby that referenced this pull request Jan 24, 2014

* ext/bigdecimal/lib/bigdecimal/util.rb (Float#to_d): fix the number
  of figures.  Patch by Vipul A M <vipulnsward@gmail.com>.
  ruby#323  fix GH-323

* test/bigdecimal/test_bigdecimal_util.rb: fix for the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

kenichi added a commit to kenichi/terraformer-ruby that referenced this pull request May 8, 2014

mrkn added a commit to ruby/bigdecimal that referenced this pull request Dec 25, 2015

* ext/bigdecimal/lib/bigdecimal/util.rb (Float#to_d): fix the number
  of figures.  Patch by Vipul A M <vipulnsward@gmail.com>.
  ruby/ruby#323  fix GH-323

* test/bigdecimal/test_bigdecimal_util.rb: fix for the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

@javierhonduco javierhonduco referenced this pull request in Shopify/measured Oct 19, 2017

Merged

Fix precision representation of floats #95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment