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. Spring学习笔记(一)

    Spring学习笔记(一) 这是一个沉淀的过程,大概第一次接触Spring是在去年的这个时候,当初在实训,初次接触Java web,直接学习SSM框架(当是Servlet都没有学),于是,养成了一个很 ...

  2. 基于 CentOS 7 搭建 Git服务器

    Git 是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. ⒈安装依赖库和编译工具 1.安装依赖库 yum install -y curl-devel expat-devel ...

  3. tp5项目报错no input file specified解决

    关于这个问题众多解决方案 1.php版本问题>5.6,把php版本改成5.5版本 2.入口文件同级目录下的.htaccess文件 RewriteRule ^(.*)$ index.php/$1 ...

  4. 并不对劲的CF1237D&E:Balanced Playlist and Binary Search Trees

    CF1237D Balanced Playlist 题意 有一个长度为\(n\)(\(n\leq 10^5\))的循环播放歌单,每首歌有一个优秀值\(a_i\)(\(a_i\leq 10^9\)). ...

  5. C# 定义热键

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  6. 【ES6 】声明变量的方式

    var function let const import class

  7. NSIS逻辑函数头文件介绍

    !include "LogicLib.nsh"使用 NSIS 的宏来提供各种逻辑基本语句,不需要预先添加函数. 基本语句 If|Unless..{ElseIf|ElseUnless ...

  8. LCN分布式事务管理(一)

    前言 好久没写东西了,9月份换了份工作,一上来就忙的要死.根本没时间学东西,好在新公司的新项目里面遇到了之前没遇到过的难题.那遇到难题就要想办法解决咯,一个请求,调用两个服务,同时操作更新两个数据库. ...

  9. 4.Linux用户与权限管理

    Linux 系统是一个多用于多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统 新增用户: useradd  新用户名 设置密码:pa ...

  10. PyCharm 创建指定版本的 Django (超详细图解)

    最近在学习胡阳老师(the5fire)的<Django企业级开发实战>,想要使用pycharm创建django项目时,在使用virtualenv创建虚拟环境后,在pycharm内,无论如何 ...