[#4858] Build fails on OSX Tiger 10.4 — noreply@...

Bugs item #1883, was opened at 2005-05-06 14:55

21 messages 2005/05/06
[#4862] Re: [ ruby-Bugs-1883 ] Build fails on OSX Tiger 10.4 — Yukihiro Matsumoto <matz@...> 2005/05/07

Hi,

[#4865] Re: [ ruby-Bugs-1883 ] Build fails on OSX Tiger 10.4 — Ryan Davis <ryand-ruby@...> 2005/05/07

[#4868] Re: [ ruby-Bugs-1883 ] Build fails on OSX Tiger 10.4 — nobu.nokada@... 2005/05/07

Hi,

[#5053] Re: [ ruby-Bugs-1883 ] Build fails on OSX Tiger 10.4 — Shugo Maeda <shugo@...> 2005/05/19

Hi,

[#5056] Re: [ ruby-Bugs-1883 ] Build fails on OSX Tiger 10.4 — Mark Hubbart <discordantus@...> 2005/05/19

On 5/19/05, Shugo Maeda <shugo@ruby-lang.org> wrote:

[#4874] - Need to reduce Ruby Sources to the Minimal — Ilias Lazaridis <ilias@...>

Hello all,

31 messages 2005/05/10
[#4879] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — Pit Capitain <pit@...> 2005/05/11

Ilias Lazaridis schrieb:

[#4883] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — Ilias Lazaridis <ilias@...> 2005/05/12

Pit Capitain wrote:

[#4884] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — Ryan Davis <ryand-ruby@...> 2005/05/12

[#4888] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — Ilias Lazaridis <ilias@...> 2005/05/12

Ryan Davis wrote:

[#4889] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — ES <ruby-ml@...> 2005/05/12

[#4890] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — Ilias Lazaridis <ilias@...> 2005/05/12

ES wrote:

[#4891] Re: [THIN] - Need to reduce Ruby Sources to the Minimal — Alexander Kellett <ruby-lists@...> 2005/05/12

On May 12, 2005, at 3:13 PM, Ilias Lazaridis wrote:

[#4911] Pointless argc check in Array#select — noreply@...

Patches item #1900, was opened at 2005-05-12 09:33

11 messages 2005/05/12

[#4919] - Hierarchical/Modular Directory Structure — Ilias Lazaridis <ilias@...>

The source-code structure should be simplified, lowering barriers for

20 messages 2005/05/12

[ ruby-Bugs-1940 ] Fixnum#** slower than Bignum#**

From: noreply@...
Date: 2005-05-21 22:22:42 UTC
List: ruby-core #5066
Bugs item #1940, was opened at 2005-05-22 00:15
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=1940&group_id=426

Category: Core
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Murphy (Kornelius Kalnbach) (murphy)
Assigned to: Nobody (None)
Summary: Fixnum#** slower than Bignum#**

Initial Comment:
(original text by Wolfgang N叩dasi-Donner)
The German Ruby forum (http://rubyforen.de) recognized a strange behaviour of the Fixnum class.

In exponentation, Fixnum is much slower than Bignum, which lets us assume that some kind of a problem is
in the implementation.

Example:

>>>>> Code (Ruby) >>>>>

require 'benchmark'

N = 10**6
B = 65891264863465298234965902602612457060348499377
F = 4628

Benchmark.bmbm(10) do |bm|
    bm.report('Bignum') do N.times do
        B ** 0.5
    end end

    bm.report('Fixnum') do N.times do
        F ** 0.5
    end end
end

>>>>> Result >>>>>
                user     system      total        real

Bignum      3.856000   0.000000   3.856000 (  3.946000)
Fixnum      7.861000   0.020000   7.881000 (  8.081000)

>>>>> End of Example >>>>>

Further investigations lead to the responsible C code:

>>>>> Code (C) >>>>>

// in numeric.c
static VALUE
fix_pow(x, y)
    VALUE x, y;
{
    if (FIXNUM_P(y)) {
        long a, b;

        b = FIX2LONG(y);
        if (b == 0) return INT2FIX(1);
        if (b == 1) return x;
        a = FIX2LONG(x);
        if (b > 0) {
            return rb_big_pow(rb_int2big(a), y);
        }
        return rb_float_new(pow((double)a, (double)b));
    }
    return rb_num_coerce_bin(x, y);  // <-- this take a lot of time
}

// ...versus...

// in bignum.c
VALUE
rb_big_pow(x, y)
    VALUE x, y;
{
    double d;
    long yy;

    if (y == INT2FIX(0)) return INT2FIX(1);
    switch (TYPE(y)) {
      case T_FLOAT:  // <-- this is fast
        d = RFLOAT(y)->value;
        break;

      case T_BIGNUM:
        ...

      case T_FIXNUM:
        ...

      default:
        return rb_num_coerce_bin(x, y);
    }
    return rb_float_new(pow(rb_big2dbl(x), d));
}

>>>>> End of Code >>>>>

If it's a feature, maybe someone can explain.
If it's a bug, maybe someone can fix ;)

German readers may be interested in the original thread: http://www.rubyforen.de/topic,749.html

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=1940&group_id=426

In This Thread

Prev Next