summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/math/decoct.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/locutus/php/math/decoct.js')
-rw-r--r--node_modules/locutus/php/math/decoct.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/node_modules/locutus/php/math/decoct.js b/node_modules/locutus/php/math/decoct.js
new file mode 100644
index 0000000..f808756
--- /dev/null
+++ b/node_modules/locutus/php/math/decoct.js
@@ -0,0 +1,19 @@
+"use strict";
+
+module.exports = function decoct(number) {
+ // discuss at: http://locutus.io/php/decoct/
+ // original by: Enrique Gonzalez
+ // bugfixed by: Onno Marsman (https://twitter.com/onnomarsman)
+ // improved by: http://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hex-in-javascript
+ // input by: pilus
+ // example 1: decoct(15)
+ // returns 1: '17'
+ // example 2: decoct(264)
+ // returns 2: '410'
+
+ if (number < 0) {
+ number = 0xFFFFFFFF + number + 1;
+ }
+ return parseInt(number, 10).toString(8);
+};
+//# sourceMappingURL=decoct.js.map \ No newline at end of file