X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fjs%2Fentropy.js;h=24fc21a47b4da47565bfde3621fd8ba6285351f2;hb=fc7c248fafef4ba2aecf9dcf4718b3d4c91d94b0;hp=b7274bbea7ccb5781aa084b45d0219d5e99e4e0e;hpb=94959756408aa60be4118ab1dceff4e71c6afdbf;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git diff --git a/src/js/entropy.js b/src/js/entropy.js index b7274bb..24fc21a 100644 --- a/src/js/entropy.js +++ b/src/js/entropy.js @@ -263,7 +263,12 @@ window.Entropy = new (function() { } // Work out the total number of bits for this many decks // See http://crypto.stackexchange.com/q/41886 - var gainedBits = Math.log2(factorial(52 * numberOfDecks)); + var gainedBits = 0; + // Equivalent of Math.log2(factorial(52*numberOfDecks)) + // which becomes infinity for numberOfDecks > 4 + for (var i=1; i<=52*numberOfDecks; i++) { + gainedBits = gainedBits + Math.log2(i); + } var lostBits = 52 * Math.log2(factorial(numberOfDecks)); var maxBits = gainedBits - lostBits; // Convert the drawn cards to a binary representation.