[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[ ...
随机推荐
- Docker CE 下载方式
1. 找到一个网址挺好的 https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/arm64/ mark 一下 以后用.
- 小记--------SparkContext初始化原理机制图解
- MySQL线程池(THREAD POOL)的原理
MySQL常用(目前线上使用)的线程调度方式是one-thread-per-connection(每连接一个线程),server为每一个连接创建一个线程来服务,连接断开后,这个线程进入thread_c ...
- 虚拟机(Vmware)安装ubuntu18.04和配置调整(二)
二.配置修改 1.修改语言环境(settings->Region & Language) 选中中文简体(Chinese(simplified)),点击Apply 中文简体语言安装完成后, ...
- Yii源码分享-底层+view层1
文件:https://files.cnblogs.com/files/cwlife/YII%E7%BB%A7%E6%89%BF%E6%A0%91.xmind.zip 视屏:https://v.qq.c ...
- 如何利用python爬虫爬取爱奇艺VIP电影?
环境:windows python3.7 思路: 1.先选取你要爬取的电影 2.用vip解析工具解析,获取地址 3.写好脚本,下载片断 4.将片断利用电脑合成 需要的python模块: ##第一 ...
- Python的argparse模块的使用
Python的argparse模块的使用 最近看到一份Pytorch代码有以下内容: # Training settings parser = argparse.ArgumentParser(desc ...
- MySQL之常见错误
1)mysql导入较大sql文件,出现MySQL server has gone away ERROR (HY000) at line in file: 'E:\xampp\htdocs\SsCpc\ ...
- go语言中获取变量类型的三种方法
package main import ( "fmt" "reflect" ) func main() { var num float64 = 3.14 // ...
- 保证在浏览器上word/图片/Excel的下载的表现形式一样
function downloadImage(src) { console.log(src); //src="http://192.168.12.50:8181/file/common/pn ...