It took some doing (and I'm not kidding), but I found a reference to using toString with a parameter..
Then a quick trip to dictionary.com to find out what the hell a radix is(don't laugh, please)
and I find that I can only conclude that number.toString([radix]) is the quickest way to to convert a number.
 
Thus: number.toString(16) would be the best way to get the hex value of a decimal number.
 
I must say I am impressed Roberto.
----- Original Message -----
Sent: Tuesday, July 31, 2001 1:52 PM
Subject: [Dynapi-Help] which is better?? non DynAPI

Hey guys,
 
last week I asked about a better way of getting hex values and R.B. told me about src\lib\dynapi\ext\functions.js (thank you for the tip :).
 
this was the function I wanted:
 
 DecToHex : function(val)
{
  lo=val%16
  val-=lo
  lo+=48
  if (lo>57) lo+=7
  hi=val/16
  hi+=48
  if (hi>57) hi+=7
  return String.fromCharCode(hi,lo)
 }
 
now after a little research I've found the toString() method but Im not sure about which is better, actually I got this function:
 
function DecToHex(w)
    {
        return (w < 16)? '0' + w.toString(16) : w.toString(16);
    }
 
So I want to know which is better, I mean speed, resources...
theres something about that method Im should know??
Im trying to learn about javascript behavior, I've had some experience with it; but there are some issues that Im still not sure about them.
Example:
    is x >> 4 faster than x / 16?? (as in C)
is there a document somewhere I should read??
 
Ok, thats my question :)
I know this is not a DynAPI issue; but DynAPI is one of the better "nice coded" scripts I've found!!
thank you all.

Reply via email to