新增: - backend/venv/ - Python 虚拟环境 - backend/start.sh - 启动脚本(使用虚拟环境) - backend/requirements.txt - 依赖列表 - .gitignore - 忽略虚拟环境和缓存文件 说明: - 每个项目使用独立虚拟环境 - 避免依赖冲突 - 启动脚本自动创建和激活虚拟环境
22 lines
498 B
JavaScript
22 lines
498 B
JavaScript
'use strict';
|
|
|
|
var $floor = require('math-intrinsics/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;
|
|
};
|