Project

General

Profile

Actions

Bug #4510

closed

Float#round(n) is O(n)

Added by regularfry (Alex Young) about 13 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2p136 (2010-12-25 revision 30365) [i686-linux]
Backport:
[ruby-core:35526]

Description

=begin
The current implementation of Float#round(n) is O(n). This causes a minor issue with rubyspec, which includes this:

0.8346268.round(-2.0**30).should == 0

which would take about 5 minutes to complete on my machine, during which time the interpreter is locked, doesn't respond to signals, and certainly won't brook any Timeout interruption.

Attached is a patch to replace the problematic part with a call to pow(3).
=end


Files

float-pow.patch (886 Bytes) float-pow.patch Patch against trunk to replace a counting loop with a call to pow(3) regularfry (Alex Young), 03/18/2011 10:24 PM
Actions #1

Updated by naruse (Yui NARUSE) about 13 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r31146.
Alex, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0