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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Caused by: java.sql.SQLSyntaxErrorException: ORA-00932: 数据类型不一致: 应为 NUMBER, 但却获得 BINARY

    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvo ...

  4. 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 ...

  5. [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& ...

  6. 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 如何在不将数字转换 ...

  7. 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 ...

  8. convert decimal to binary

    public class Solution { public static void main(String[] args) { ; String str = ""; ) { ; ...

  9. convert decimal to binary using inbuilt function

    package testpacknm; import java.util.Scanner; public class testcnm { public static void main(String[ ...

随机推荐

  1. [转帖]开始使用Chronograf

    地址:https://docs.influxdata.com/chronograf/v1.6/introduction/getting-started/ https://www.cnblogs.com ...

  2. 【LOJ】#3093. 「BJOI2019」光线

    LOJ#3093. 「BJOI2019」光线 从下到上把两面镜子合成一个 新的镜子是\((\frac{a_{i}a_{i + 1}}{1 - b_{i}b_{i + 1}},b_{i} + \frac ...

  3. python虚拟环境的的使用

    基于创建虚拟环境 virtualenv 安装 pip3 install virtualenv 通过virtulaenv创建虚拟环境 virtualenv luffycity --python=C:\P ...

  4. mongodb 批量替换内容的语句

    // 注意上面的集合要和下面的集合名称相同 db.rand_web_test.find( { 'content': /^.*要替换的字符串.*$/ } ).forEach( function (ite ...

  5. redis 命令 setbit、bitcount、getbit、bitop

    1.SETBIT key offset value 对 key 所储存的字符串值,设置或清除指定偏移量上的位(bit). 在redis中,存储的字符串都是以二级制的进行存在的. 举例: 设置一个 ke ...

  6. error: [Errno 13] Permission denied: '/usr/local/lib/处理方法

    在ubuntu系统下使用pip 命令安装包时,出现以下类似错误提示: error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/di ...

  7. 【原创】大数据基础之ETL vs ELT or DataWarehouse vs DataLake

    ETL ETL is an abbreviation of Extract, Transform and Load. In this process, an ETL tool extracts the ...

  8. ZROI2018暑期集训B班训练赛#1解题报告

    版权原因不公布题目信息 A 分析 虽然前一天搞到比较晚,考场上还是比较快的想到了正解,可惜姿势水平低被卡到了64(进入高中不知道考过多少次64了...) 这题有个比较明显且\(naive\)的做法是用 ...

  9. java基础4(线程)

    1.请简单描述什么是并行,什么是并发? 并行:指两个或多个事件在同一时刻发生(同时发生). 并发:指两个或多个事件在同一个时间段内发生. 通俗易懂版: 你吃饭吃到一半,电话来了,你一直到吃完了以后才去 ...

  10. 6 java 笔记

    1 java的类通过构造器来创建该类的对象 2 java提供extends关键字来实现子类继承父类 3 初始化块总是在构造器调用之前被执行 4 可以吧java中的类当成一种自定义的类型 5 类定义的变 ...