octave-patch-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-patch-tracker] [patch #7825] built-in versions of base2dec and d


From: Dan Sebald
Subject: [Octave-patch-tracker] [patch #7825] built-in versions of base2dec and dec2base
Date: Mon, 30 Jul 2012 04:24:32 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.6.24-1.fc14 Firefox/3.6.24

Follow-up Comment #1, patch #7825 (project octave):

I see that there is a standard C++ library routine that returns both the
quotient and remainder of a division.  So I tried the following:

  for (int j = LEN-1; j >= 0; j--)
    {
      div_t division;
      division = div (divisor, BASE);

      S[j] =  mapstr[division.rem];

      divisor = division.quot;
      if (divisor == 0)
        break;
    }

To my surprise, this is slower.  Not much of an optimization in that function
I guess:

COMMAND                      BUILT-IN        BUILT-IN
                             DIVIDE          div_t
                             MULTIPLY           div()
_______                      ________        _______

dec2bin(<int vector>)        0.22697         0.25996
dec2bin(<cell vector>)       0.23996         0.28496
dec2hex(<int vector>)        0.11998         0.12998
dec2hex(<cell vector>)       0.13898         0.16198
dec2base(<int vec>, '01')    0.22497         0.24796
dec2base(<cell vec>, '01')   0.23996         0.28396

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?7825>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]