How can I type a complex function in cell ??

26 views
Skip to first unread message

Joyce Tzou

unread,
May 15, 2014, 12:00:03 AM5/15/14
to jquer...@googlegroups.com
Hi, Robert,

I need to use a complex function in cell, like following formula : 

1.  =IF(I43=0,"NA",IF((MOD(HEX2DEC(H43)*65536,I43*2^20))=0,"OK","not alignment"))
2. =DEC2HEX(HEX2DEC(H40)*65536,8)

Could it work in jQuery.sheet ?


by the way, DEC2HEX, HEX2DEC, MOD not in Math function
I try the function DEC2HEX (--> it's work.) & HEX2DEC (--> it's not work.)
reference DEC2HEX.

I'll try other math function...Maybe you have better solution?

-------------------
/**
* math function
* @returns {number}
         * @memberOf jFN
*/
DEC2HEX:function(){
var result = 0,
                v = arrHelpers.toNumbers(arguments),
                i = v.length - 1;

            if (i < 0) {
                return result;
            }
if (i > 1){
return result;
}
do {
var n = parseInt(v[i]); var c = 'ABCDEF';
var b = n / 16; var r = n % 16; b = b-(r/16); 
b = ((b>=0) && (b<=9)) ? b : c.charAt(b-10);
result=((r>=0) && (r<=9)) ? b+''+r : b+''+c.charAt(r-10);
            } while (i--);
return result;
},
-------------------


Joyce Tzou

unread,
May 15, 2014, 1:39:28 AM5/15/14
to jquer...@googlegroups.com
I found  MOD math function..

Joyce Tzou於 2014年5月15日星期四UTC+8下午12時00分03秒寫道:

Robert Plummer

unread,
May 15, 2014, 7:22:46 AM5/15/14
to Joyce Tzou, jquer...@googlegroups.com
The formula looks like it would work fine, but there is a lack of the javascript functions DEC2HEX, HEX2DEC, MOD.  If you feel like contributing them, it would greatly increase the value of jQuery.sheet.  I always love a good pull request.  Here is HEX2DEC in vbscript, would be easy to convert: http://www.vbforums.com/showthread.php?532656-RESOLVED-EXCEL-2003-HEX2DEC-equivalent
--
Robert Plummer

Joyce Tzou

unread,
May 15, 2014, 9:48:11 PM5/15/14
to jquer...@googlegroups.com
Hi, Robert, 

thanks for you reply,
I also found a javascript sample, like your vbscript sample.

Now, HEX2DEC is work fine.
-------------------------------------
/**
* math function
* @returns {number}
         * @memberOf jFN
*/
HEX2DEC:function(v){
var result = 0,  
max = v.length-1;
for (var i=max; i>=0; i--){
  var digit = v.charAt(i).toUpperCase();
  switch(digit)
 {
 case "A": digit = 10; break;
 case "B": digit = 11; break;
 case "C": digit = 12; break;
 case "D": digit = 13; break;
 case "E": digit = 14; break;
 case "F": digit = 15; break;
 }
 result = result+(digit * Math.pow(16, +max-i));
}
return result;
},
-------------------------------------


Robert Plummer於 2014年5月15日星期四UTC+8下午7時22分46秒寫道:

Robert Plummer

unread,
May 16, 2014, 8:13:49 PM5/16/14
to Joyce Tzou, jquer...@googlegroups.com
Care to pull request?
--
Robert Plummer

Joyce Tzou

unread,
May 18, 2014, 11:49:05 PM5/18/14
to jquer...@googlegroups.com

Your mean is using Github's Pull Requests to record HEX2DEC / DEC2HEX ?


Robert Plummer於 2014年5月17日星期六UTC+8上午8時13分49秒寫道:

Robert Plummer

unread,
May 19, 2014, 12:23:44 AM5/19/14
to Joyce Tzou, jquer...@googlegroups.com

Yes.  What you would do is fork my code of github, then modify the file, commit and pish, then pull request it.  At that point I can merge it back in to the primary project.

Reply all
Reply to author
Forward
0 new messages