JSFiddle - React, Tailwind, and code Playground
by msm595
JavaScript
function pow(num, tob) {
var fin="";
var it=Math.floor(Math.log(num)/Math.log(tob));
//alert(it);
//fin+=it;
//num-=Math.pow(tob,it);
for(var i=it;i>=0;i--) {
var temp=Math.floor(num/Math.pow(tob,i));
//alert(i+" "+temp)
fin+=" "+temp;
num-=Math.pow(tob,i)*temp;
//alert(num);
}
return fin;
}
function ipow(num, fob) { //to base 10 from `fob`
var fin="";
var peices=num.split(',').reverse();
for(var i=0;i<peices.length;i++) {
fin=","+peices[i]*Math.pow(fob, i)+fin;
}
return fin.substring(1);
}
function divBig(x,n) { //big, int
x=x.split(','),r=0;
for(var i=0;i<x.length;i++) {
r=r*Math.pow(2,15)+x[i]*1;
x[i]=Math.floor(r/n);
r=r%n;
}
return (x.join(','));
}
//for(var i=9.6;i<10.5;i+=.01) {
console.log(pow(134841509989, Math.pow(2,15)));
console.log(divBig("125,19036,10341", 10));
console.log(pow(13484150998, Math.pow(2,15)));
//}