peterolson / BigInteger.js

An arbitrary length integer library for Javascript
The Unlicense
1.12k stars 187 forks source link

Why it is still SmallInteger ? #141

Closed ying2025 closed 6 years ago

ying2025 commented 6 years ago

image var bigInterger = require("big-integer"); // 引入大整型 image

peterolson commented 6 years ago

I'm not sure I understand what your question is?

Please paste the code you are having problems with in plain text. It is more difficult to try to copy code from images.

ying2025 commented 6 years ago

Ok, It is not problem now. But I have a another question.

b._N = new Array(b.byteLen);
    var sss = bigInterger(b.iN).toString();
    console.log("b.iN",b.iN)
    console.log("sss" ,sss)
    var ssda = Str2Bytes(sss);
    console.log(ssda)
function Str2Bytes(str) {  
    var pos = 0; 
    var len = str.length;  
    if(len%2 != 0) {  
       return null;   
    }  
    len /= 2;  
    var hexA = new Array();  
    for(var i=0; i<len; i++) {  
       var s = str.substr(pos, 2);  
       var v = parseInt(s, 16);  
       hexA.push(v);  
       pos += 2; 
    }  
    return hexA;  
}   

The following is the output

b.iN { [Number: 1.6760943441033507e+308]
  value: 
   [ 67939,
     5889735,
     6593896,
     1036967,
     4829064,
     4094822,
     768368,
     2990254,
     4895226,
     4129985,
     5494191,
     9133571,
     5831626,
     568363,
     222332,
     3702788,
     5321825,
     3845194,
     8492691,
     7619782,
     4262147,
     374669,
     7660561,
     6376737,
     8979516,
     2848084,
     105463,
     4747039,
     6478993,
     5738918,
     13916,
     5152380,
     5515315,
     5859473,
     980086,
     4209303,
     3904557,
     2532981,
     2601355,
     4350090,
     3952376,
     613451,
     4410335,
     6760943,
     1 ],
  sign: false,
  isSmall: false }
sss 167609434410335061345139523764350090260135525329813904557420930309800865859473551531551523800013916573891864789934747039010546328480848979516637673776605610374669426214776197828492691384519453218253702788022233205683635831626913357154941914129985489522629902540768368409482248290641036967659389658897350067939
null
ying2025 commented 6 years ago

I want to get sss, but it's empty. image

image

peterolson commented 6 years ago

Sorry, I do not understand your questions. Please improve your questions: