[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[ ...
随机推荐
- scrapy生成json中文为ASCII码解决
修改pipelines.py 即可 修改内容如下: import json import codecs import os class BaiduNewsPipeline(object): #增加的 ...
- Oracle 的查询-scott用户介绍
scott用户 密码tiger 解锁scott用户 alter user scott account unlock; 解锁scott密码(也可重置密码) alter user scott identi ...
- 小记--------spark的Master的Application注册机制源码分析及Master的注册机制原理分析
原理图解: Master类位置所在:spark-core_2.11-2.1.0.jar的org.apache.spark.deploy.master下的Master类 //截取了部分代码 //处理 ...
- C#面向对象13 文件类操作 Path/File/FileStream
1.path using System; using System.Collections.Generic; using System.Linq; using System.Text; using S ...
- http请求204
项目中发现一个奇怪的问题,请求的时候同一个接口有两个请求,而且有一个状态为204,有一个为200 在网上查看资料后得知,是因为跨域而引起的,OPTIONS是一种“预检请求”,浏览器在处理跨域访问的请求 ...
- Entity Framework:三种开发模式实现数据访问
原文地址 http://blog.csdn.net/syaguang2006/article/details/19606715 前言 Entity Framework支持Database First. ...
- MySQL 5.7.18 zip版本的安装使用方法
转自:https://www.cnblogs.com/nepulgh/p/7152618.html MySQL 5.7.18 zip版本的安装使用方法 这个版本的MySQL不像那种点击就可以立即安装, ...
- (转)Java垃圾回收基本过程
本编博客内容来自oschina,是一篇译文,文中图片比较直观的介绍了JVM进行垃圾回收的过程.原文内容来自oracle官网:Java Garbage Collection Basics oschina ...
- php打包下载以及断点续传
php下载单文件 以及 多文件打包下载,支持断点续传 断点续传的功能未经验证 需要nginx或者apache服务器指定静态文件,png, mp4, zip等后缀文件的目录, 直接实例化并调用 down ...
- STM32WB RTC
实时时钟 (RTC) 是一个独立的 BCD 定时器/计数器.RTC 提供一个带可编程闹钟中断的日历时钟以及一个具有中断功能的周期性可编程唤醒标志.RTC 还包含用于管理所有低功耗模式的自动唤醒单元.两 ...