MikeMcl/decimal.js — pull request #12 by BigFav (2014-12-08 11:16:55+00:00)
Title: Introducing bitwise ops

All of the tests pass. The two input gate ops are a little slow (`&`, `|`, and `^`), but they are working.

I tried to omit the toString() calls in bitwise, but the Decimal calls to Mod were more expensive. I also tried to capture cases where the two numbers' bits don't overlap (thus replacable with simple addition, one of the values, etc.), but that barely saw a speedup and it added a decent amount of code. It was a lazy function that only checked for base 10, in the hopes of being computationally cheap. Here it is just in case:
```javascript
function digitsOverlap( x, y ) {
var xStr = x['toString'](),
yStr = y['toString'](),
xEindex = xStr.indexOf( 'e' ) - 3,
yEindex = yStr.indexOf( 'e' ) - 3;

if (xEindex < 0) {
xEindex = xStr.length - 2;
} else if (x['s'] < 0) {
--xEindex;
}
if (yEindex < 0) {
yEindex = yStr.length - 2;
} else if (y['s'] < 0) {
--yEindex;
}

var xLowestDigit = x['e'] - xEindex,
yLowestDigit = y['e'] - yEindex;

return (xLowestDigit <= y['e'] + 1) && (yLowestDigit <= x['e'] + 1);
}
```

Feel free to comment on any change you see.