refactor start
This commit is contained in:
parent
bd49791e06
commit
e46d25f0b7
16699 changed files with 2 additions and 1484887 deletions
23
home/ags/node_modules/es-abstract/helpers/intToBinaryString.js
generated
vendored
23
home/ags/node_modules/es-abstract/helpers/intToBinaryString.js
generated
vendored
|
|
@ -1,23 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $floor = GetIntrinsic('%Math.floor%');
|
||||
|
||||
// https://runestone.academy/ns/books/published/pythonds/BasicDS/ConvertingDecimalNumberstoBinaryNumbers.html#:~:text=The%20Divide%20by%202%20algorithm,have%20a%20remainder%20of%200
|
||||
|
||||
module.exports = function intToBinaryString(x) {
|
||||
var str = '';
|
||||
var y;
|
||||
|
||||
while (x > 0) {
|
||||
y = x / 2;
|
||||
x = $floor(y); // eslint-disable-line no-param-reassign
|
||||
if (y === x) {
|
||||
str = '0' + str;
|
||||
} else {
|
||||
str = '1' + str;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue