Skip to content

Add new Bitwise Functions introduced in MS Excel 2013 #603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 22, 2018
Merged

Conversation

MarkBaker
Copy link
Member

  • Added calculation engine support for the new bitwise functions that were added in MS Excel 2013
    • BITAND() Returns a Bitwise 'And' of two numbers
    • BITOR() Returns a Bitwise 'Or' of two number
    • BITXOR() Returns a Bitwise 'Exclusive Or' of two numbers
    • BITLSHIFT() Returns a number shifted left by a specified number of bits
    • BITRSHIFT() Returns a number shifted right by a specified number of bits

This is:

- [ ] a bugfix
- [X] a new feature

Checklist:

Why this change is needed?

This change provides the new Bitwise functions that were introduced in MS Excel 2013 for the calculation engine.

MarkBaker added 3 commits July 16, 2018 19:43
… were added in MS Excel 2013

  - BITAND()     Returns a Bitwise 'And' of two numbers
  - BITOR()      Returns a Bitwise 'Or' of two number
  - BITXOR()     Returns a Bitwise 'Exclusive Or' of two numbers
  - BITLSHIFT()  Returns a number shifted left by a specified number of bits
  - BITRSHIFT()  Returns a number shifted right by a specified number of bits
@MarkBaker MarkBaker self-assigned this Jul 16, 2018
Copy link
Member

@PowerKiKi PowerKiKi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments, then it could probably be merged directly

@@ -2423,6 +2423,175 @@ public static function erfVal($x)
return self::$twoSqrtPi * $sum;
}

protected static function validateBitwiseArgument($value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be private to limit our API surface and make future maintenance easier. Also maybe a doc block would be nice to document types.

Also could/should the Functions::flattenSingleValue() call be part of this method ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid comments; and I've also tightened up the validation to handle the different responses for different errors. See my next commit.
I'm very much tempted to write a dedicated validator class, that can be called passing in the argument with a set of validation rules/responses; but that's a more significant piece of work that really needs its own PR rather than bundling with this one.

@MarkBaker MarkBaker merged commit 67cdee6 into develop Jul 22, 2018
@MarkBaker MarkBaker deleted the bitwise branch July 25, 2018 14:57
Dfred pushed a commit to Dfred/PhpSpreadsheet that referenced this pull request Nov 20, 2018
* - Added calculation engine support for the new bitwise functions that were added in MS Excel 2013
  - BITAND()     Returns a Bitwise 'And' of two numbers
  - BITOR()      Returns a Bitwise 'Or' of two number
  - BITXOR()     Returns a Bitwise 'Exclusive Or' of two numbers
  - BITLSHIFT()  Returns a number shifted left by a specified number of bits
  - BITRSHIFT()  Returns a number shifted right by a specified number of bits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants