oct.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createOct = void 0;
  6. var _factory = require("../../utils/factory.js");
  7. var name = 'oct';
  8. var dependencies = ['typed', 'format'];
  9. /**
  10. * Format a number as octal.
  11. *
  12. * Syntax:
  13. *
  14. * math.oct(value)
  15. *
  16. * Examples:
  17. *
  18. * //the following outputs "0o70"
  19. * math.oct(56)
  20. *
  21. * See also:
  22. *
  23. * bin
  24. * hex
  25. *
  26. * @param {number} value Value to be stringified
  27. * @param {number} wordSize Optional word size (see `format`)
  28. * @return {string} The formatted value
  29. */
  30. var createOct = (0, _factory.factory)(name, dependencies, function (_ref) {
  31. var typed = _ref.typed,
  32. format = _ref.format;
  33. return typed(name, {
  34. 'number | BigNumber': function numberBigNumber(n) {
  35. return format(n, {
  36. notation: 'oct'
  37. });
  38. },
  39. 'number | BigNumber, number': function numberBigNumberNumber(n, wordSize) {
  40. return format(n, {
  41. notation: 'oct',
  42. wordSize: wordSize
  43. });
  44. }
  45. });
  46. });
  47. exports.createOct = createOct;