0% found this document useful (0 votes)
29 views

BPJ Lesson 14

This document discusses different number bases including decimal, binary, octal, and hexadecimal. It provides examples of converting between the bases, such as representing 147 in decimal as 10010011 in binary. Techniques are presented for storing numbers in different bases using prefixes like 0b for binary and 0 for octal. Common operations on different bases are also demonstrated, such as binary addition and octal multiplication.

Uploaded by

api-307093783
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

BPJ Lesson 14

This document discusses different number bases including decimal, binary, octal, and hexadecimal. It provides examples of converting between the bases, such as representing 147 in decimal as 10010011 in binary. Techniques are presented for storing numbers in different bases using prefixes like 0b for binary and 0 for octal. Common operations on different bases are also demonstrated, such as binary addition and octal multiplication.

Uploaded by

api-307093783
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Lesson 14..

Binary, Hex, and Octal


similarities
Decimal, base 10
10
10

10
10

Binary, base 2
2
2

2
10 bin (2 dec )

eight bits

byte
mb

Store an octal number:


the leading 0 indicates octal format
Convert an integer variable to a hex String:
f3d hex
Convert an integer variable to a binary String:
111100111101 bin
Convert an integer variable to an octal String:
7475 oct

int

int

Base conversion using parseInt:


String

int

Integer.parseInt(3w4br, 35)
A technique for converting 147 from decimal to binary:

10010011 bin = 147 dec


A technique for converting 3741 from decimal to hex:

An octal multiplication example (

Binary addition:

A trick for converting binary into hex:

):

You might also like