[Algorithm] Convert a number from decimal to binary
125, how to conver to binary number?

function DecimalToDinary (n) {
let temp = n;
let list = [];
if (temp <= 0) {
return '0000';
}
while (temp > 0) {
let rem = temp % 2;
list.push(rem);
temp = parseInt(temp / 2, 10);
}
return list.reverse().join('');
}
console.log(DecimalToDinary(125)) //
[Algorithm] Convert a number from decimal to binary的更多相关文章
- 38. leetcode 405. Convert a Number to Hexadecimal
405. Convert a Number to Hexadecimal Given an integer, write an algorithm to convert it to hexadecim ...
- LeetCode_405. Convert a Number to Hexadecimal
405. Convert a Number to Hexadecimal Easy Given an integer, write an algorithm to convert it to hexa ...
- Caused by: java.sql.SQLSyntaxErrorException: ORA-00932: 数据类型不一致: 应为 NUMBER, 但却获得 BINARY
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvo ...
- java.sql.SQLSyntaxErrorException: ORA-00932: 数据类型不一致: 应为 NUMBER, 但却获得 BINARY
2019-07-24 17:24:35 下午 [Thread: http-8080-4][ Class:net.sf.ehcache.store.disk.Segment Method: net.sf ...
- [Javascript] Use Number() to convert to Number if possilbe
Use map() and Number() to convert to number if possilbe or NaN. var str = ["1","1.23& ...
- how to convert a number to a number array in javascript without convert number to a string
how to convert a number to a number array in javascript without convert number to a string 如何在不将数字转换 ...
- Java – Convert IP address to Decimal Number
In this tutorial, we show you how to convert an IP address to its decimal equivalent in Java, and vi ...
- convert decimal to binary
public class Solution { public static void main(String[] args) { ; String str = ""; ) { ; ...
- convert decimal to binary using inbuilt function
package testpacknm; import java.util.Scanner; public class testcnm { public static void main(String[ ...
随机推荐
- python列表与字符串、元组的区别以及列表引用的方式
一.字符串 字符串也可以用下标取值.切片.for循环.len()取长度以及 in 和 not in 来进行操作. 但字符串是不可变的,不能被更改.只能构造一个“新的”字符串来存取你想要修改后的数据. ...
- 解决连接HIS连接不上数据库的问题
运行程序单步运行,设置断点 配置HIS中的 GetDataBaseInfo类,将与本机无关的配置函数全部删除,(按照DMHospital.ini文件来对照修改),如下图: 往数据库中所创建的表中添加数 ...
- mount.nfs: access denied by server while mounting
在利用centos7系统搭建NFS服务时出现如下问题,百度后才解决 因为当时在服务器端vim /etc/exports 时, 我只写了 这一行 /home/wjs-nfs *(ro) (没想到偷懒出 ...
- springboot打包的jar项目,不需要安装jdk环境启动
因为服务器上是JDK7,而springboot至少用JDK8才行,但是又因为是很老的项目,不是很清楚能不能换JDK8,有风险,因此选择以前项目用JDK7,而新的springboot用JDK8.步骤一: ...
- [经验分享] Docker网络解决方案-Weave部署记录
前面说到了Flannel的部署,今天这里说下Docker跨主机容器间网络通信的另一个工具Weave的使用.当容器分布在多个不同的主机上时,这些容器之间的相互通信变得复杂起来.容器在不同主机之间都使用的 ...
- zabbix-自定义告警(二)
实现自定义监控 文章引用:https://www.cnblogs.com/clsn/p/7885990.html#auto_id_28 一.实现自定义监控 说明zabbix自带模板Template O ...
- ssh无密登录_集群分发脚本xsync
1.ssh免密登录 ssh ip地址 [root@192 ~]# ssh 192.168.1.102 root@192.168.1.102's password: Last login: Mon Fe ...
- sql server存储过程回滚事务
SET NOCOUNT ON这个很常用 作用:阻止在结果集中返回显示受T-SQL语句或则usp影响的行计数信息. 当SET ONCOUNT ON时候,不返回计数,当SET NOCOUNT OFF时候, ...
- oracle sqlplus执行sql语句字符集问题
因为业务需要,现将一些包含中文的insert语句导入到oracle数据库中,由于数据量比较大,通过pl/sql*plus导入时非常慢(实测1.5M的文件大概执行20分钟),现在oracle服务器sql ...
- Java 实现 海康摄像头抓拍图像 Windows、Linux
先抱怨一下,打死都想不到,海康的摄像头SDK居然是一个Java类,还有必须的两个jar包(jna.jar,examples.jar).鬼能想得到会这么命名. 下面开始吧. Windows 把从官网下载 ...