bitNot.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { bitNotBigNumber } from '../../utils/bignumber/bitwise.js';
  2. import { deepMap } from '../../utils/collection.js';
  3. import { factory } from '../../utils/factory.js';
  4. import { bitNotNumber } from '../../plain/number/index.js';
  5. var name = 'bitNot';
  6. var dependencies = ['typed'];
  7. export var createBitNot = /* #__PURE__ */factory(name, dependencies, _ref => {
  8. var {
  9. typed
  10. } = _ref;
  11. /**
  12. * Bitwise NOT value, `~x`.
  13. * For matrices, the function is evaluated element wise.
  14. * For units, the function is evaluated on the best prefix base.
  15. *
  16. * Syntax:
  17. *
  18. * math.bitNot(x)
  19. *
  20. * Examples:
  21. *
  22. * math.bitNot(1) // returns number -2
  23. *
  24. * math.bitNot([2, -3, 4]) // returns Array [-3, 2, -5]
  25. *
  26. * See also:
  27. *
  28. * bitAnd, bitOr, bitXor, leftShift, rightArithShift, rightLogShift
  29. *
  30. * @param {number | BigNumber | Array | Matrix} x Value to not
  31. * @return {number | BigNumber | Array | Matrix} NOT of `x`
  32. */
  33. return typed(name, {
  34. number: bitNotNumber,
  35. BigNumber: bitNotBigNumber,
  36. 'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self))
  37. });
  38. });