Hexadecimal
To create a hexadecimal literal, you make the first two characters 0x or 0X. The hexadecimal digits are 0 through 9, and A through F. Letters may be in uppercase or lowercase.
<!DOCTYPE html>
<html>
<head>
<title>Number Example</title>
<script type="text/javascript">
var hexNum = 0xA;
document.writeln(hexNum); //10
</script>
</head>
<body>
</body>
</html>
The hexadecimal numbers are converted to decimal numbers in all arithmetic operations.
<!DOCTYPE html>
<html>
<head>
<title>Number Example</title>
<script type="text/javascript">
var hexNum = 0xA;
document.writeln(hexNum); //10
var aNum = 123;
document.writeln(hexNum + aNum); //133
</script>
</head>
<body>
</body>
</html>
Home
JavaScript Book
Language Basics
JavaScript Book
Language Basics
Data Types:
- JavaScript Data Types
- typeof Operator
- The Undefined Type
- null Type
- null vs undefined
- Boolean Type
- Boolean() casting function
- The Literials of Number Type
- Octal Integer
- Hexadecimal
- Floating-Point Values
- Value range
- NaN
- Number Conversions:Number(), parseInt() and parseFloat()
- Number() function
- parseInt()
- parseFloat()
- The String Type
- String Literals and Escapes
- Get the String Length
- Converting to a String with toString() method
- Convert Number to String with radix
- Convert to String with String() casting function