Bin to Dec to Hex in JavaScript

You can find here how to convert between bin, dec, hex values in JavaScript programming language with examples.

Bin to Dec in JavaScript

Function parseInt() parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems). [reference]

Example

How to convert value 11111111 in bin to dec in JavaScript.

var dec = parseInt("11111111", 2);
Output: 255

Dec to Bin in JavaScript

Function toString() returns a string representing the specified Number object. [reference]

Example

How to convert value 185 in dec to bin in JavaScript.

var bin = (185).toString(2);
Output: "10111001"

Bin to Hex in JavaScript

Function parseInt() parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems). [reference]

 

Function toString() returns a string representing the specified Number object. [reference]

Example

How to convert value 101011 in bin to hex in JavaScript.

var hex = parseInt("101011", 2).toString(16);
Output: "2b"

Hex to Bin in JavaScript

Function parseInt() parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems). [reference]

 

Function toString() returns a string representing the specified Number object. [reference]

Example

How to convert value 3ef in hex to bin in JavaScript

var bin = parseInt("3ef", 16).toString(2);
Output: "1111101111"

Dec to Hex in JavaScript

Function toString() returns a string representing the specified Number object. [reference]

Example

How to convert value 185 in dec to hex in JavaScript.

var hex = (185).toString(16);
Output: "b9"

Hex to Dec in JavaScript

Function parseInt() parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems).[reference]

Example

How to convert value 3ef in hex to dec in JavaScript.

var dec = parseInt("3ef", 16);
Output: 1007

Bin to dec to hex in Java

You can find here how to convert between bin, dec, hex values in Java programming language with examples.

Bin to Dec in Java

Function public static int parseInt(String s, int radix) throws NumberFormatException parses the string argument as a signed integer in the radix specified by the second argument. [reference]

Example

How to convert value 1110010 in bin to decimal in Java.

Integer.parseInt("1110010", 2);
Output: 114

Dec to Bin in Java

Function public static String toBinaryString(int i) returns a string representation of the integer argument as an unsigned integer in base 2. Leading zeroes are eliminated from the output. [reference]

Example

How to convert value 5 in dec to bin in Java.

Integer.toBinaryString(5)
Output: 101

Bin to Hex in Java

Function public static int parseInt(String s, int radix) throws NumberFormatException parses the string argument as a signed integer in the radix specified by the second argument.[reference]

Example

How to convert value 101011 in bin to hex in Java.

int dec = Integer.parseInt("101011", 2);
String hex = Integer.toString(dec, 16);
Output: 2b

Hex to Bin in Java

Function public String toString(int radix)returns the String representation of this BigInteger in the given radix. The result does not contain leading zeroes. [reference]

Example

How to convert value 3ef in hex to bin in Java

import java.math.BigInteger;

BigInteger dec = new BigInteger("3ef", 16); 
String bin = dec.toString(2);
Output: 1111101111

Dec to Hex in Java

Function public static String toHexString(int i) returns a string representation of the integer argument as an unsigned integer in base 16.[reference]

Example

How to convert value 185 in dec to hex in Java.

Integer dec = Integer.toHexString(185)
Output: b9

Hex to Dec in Java

Function public BigInteger(String val, int radix)translates the String representation of a BigInteger in the specified radix into a BigInteger. [reference]

Example

How to convert value 3ef in hex to dec in Java.

import java.math.BigInteger;

BigInteger dec = new BigInteger("3ef", 16);
Output: 1007

Bin to dec to hex in Python 3

You can find here how to convert between bin, dec, hex values in Python3. Python is an interpreted, object oriented and general purpose programming language. Object oriented approach helps programmers write clear, logical code for small or large projects. Python is dynamically typed and garbage collected. For converting from bin to dec to hex in Python you can use build in functions like int, format, hex or bin.

Bin to Dec in Python 3

Function int(x, base=2)returns an integer object constructed from a number or string x with the base 2. [reference]

Example

How to convert value 11111111 in bin to dec in Python.

>>> int('11111111', 2)
Output: 255

Dec to Bin in Python 3

Function format(value[, format_spec]) converts a value to a “formatted” representation, as controlled by format_spec. [reference]

Example

How to convert value 5 in dec to bin in Python.

>>> format(5, "b")
Output: 101

Bin to Hex in Python 3

Function hex(x) converts an integer number to a lowercase hexadecimal string prefixed with “0x”. If x is not a Python int object, it has to define an __index__() method that returns an integer. [reference]

Example

How to convert value 101011 in bin to hex in Python.

>>> hex(int('101011', 2))
Output: '0x2b'

Hex to Bin in Python 3

Function bin(x) converts an integer number to a binary string prefixed with “0b”. The result is a valid Python expression. If x is not a Python int object, it has to define an __index__() method that returns an integer. [reference]

Example

How to convert value 3ef in hex to bin in Python.

>>> bin(int("3ef", 16))
Output: '0b1111101111'

Dec to Hex in Python 3

Function hex(x) converts an integer number to a lowercase hexadecimal string prefixed with “0x”. If x is not a Python int object, it has to define an __index__() method that returns an integer. [reference]

Example 1

How to convert value 185 in dec to hex in Python.

>>> hex(185)
Output: '0xb9'

Example 2

How to convert value 185 in dec to hex in Python without 0x.

>>> format(185, 'x')
Output: 'b9'

Hex to Dec in Python 3

Function int(x, base=16)returns an integer object constructed from a number or string x with the base 16. [reference]

Example

How to convert value 3ef in hex to dec in Python.

>>> int("3ef", 16)
Output: 1007