Skip to content

Commit

Permalink
Use improved multiply function
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge committed Sep 2, 2010
1 parent aef575b commit 59dc842
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/mysql/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,12 @@ exports.hashPassword = function(password) {
}

// Provided by Herbert Vojčík, needed to deal with float point precision problems in JS
exports.multiply = function(x, y) {
var lowX = x & 0xffff,
highX = (x >> 16) & 0xffff,
lowY = y & 0xffff,
highY = (y >> 16) & 0xffff
result =
0x10000 * ((highX * lowY + lowX * highY) & 0xffff) + lowY * lowX;
exports.multiply = function(a, b) {
var a1 = a >>> 16,
a2 = a & 0xffff;
// Precondition: b is in 32bit range

//result = result & 0xffffffff;
result = result % 0x100000000;
return result;
return ((a1 * b << 16) + a2 * b) >>> 0;
}

exports.int32Write = function(buffer, number, offset) {
Expand Down

0 comments on commit 59dc842

Please sign in to comment.