SlideShare a Scribd company logo
1 of 10
PRIMITIVE TYPES IN
JAVA
Primitive Types
Operations on Primitive Types
Review of Binary Numbers
• Numbering systems
• Counting in Decimal
• Counting in Binary
• Counting in Hexadecimal
Decimal Numbers
Decimal Numbers
Given 98, what is the next number? 99
Given 99, what is the next number? 100
Why?
In decimal, we use ten symbols, 0,1,2,3,4,5,6,7,8,9
When we increment a number, we increase the smallest
value by one. If that symbol is already the highest symbol
(9 in decimal), we repeatedly set it back to the lowest
symbol (0 in all numbering systems) and increment the
next symbol.
Binary Numbers
Binary Numbers
Given 010, what is the next number? 011
Given 011, what is the next number? 100
Why?
In binary, we use two symbols, 0,1
When we increment a number, we increase the smallest
value by one. If that symbol is already the highest symbol
(1 in binary), we repeatedly set it back to the lowest symbol
(0 in all number systems) and increment the next symbol.
Counting from zero to fifteen in binary
0000 zero
0001 one
0010 two
0011 three
0100 four
0101 five
0110 six
0111 seven
1000 eight
1001 nine
1010 ten
1011 eleven
1100 twelve
1101 thirteen
1110 fourteen
1111 fifteen
Hexadecimal Numbers
Binary Numbers
Given 0FE, what is the next number? 0FF
Given 0FF, what is the next number? 100
Why?
In hexadecimal, we use sixteen symbols,
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
When we increment a number, we increase the smallest
value by one. If that symbol is already the highest symbol
(F in hexadecimal), we repeatedly set it back to the lowest
symbol (0 in all number systems) and increment the next
symbol.
Relationship between Binary and Hex
Since hexadecimal has 16 symbols and in binary 4 bits
(binary digits) exactly maps to 16 different values
0000 to 1111 represents zero through fifteen in binary
0 to F represents zero through fifteen in hex
Hexadecimal can be thought of as shorthand for binary.
Ex) x01FB = b0000 0001 1111 1011
Primitive types in Java
Type Contains Default Size Min Max
boolean true/false false 1bit n/a n/a
char Unicode u0000 16 bits u0000 uFFFF
byte Signed integer 0 8 bits -128 +127
short Signed integer 0 16 bits -32,768 +32,767
int Signed integer 0 32 bits -2 Gig +2 Gig -1
long Signed Integer 0 64 bits - Huge + Huge
float IEEE 754 float 0.0 32 bits - Large + Large
double IEEE 754 float 0.0 64 bits - Huge + Huge
Note:
8 bits can represent xFF = 256 numbers
16 bits can represent xFFFF = 65,532 numbers = 64 K
32 bits can represent XFFFF FFFF = 4,294,967,296 numbers = 4 Gig
JAVA character codes
• Dec Char Dec Char Dec Char Dec Char
• --------- --------- --------- ----------
• 0 NUL (null) 32 SPACE 64 @ 96 `
• 1 SOH (start of heading) 33 ! 65 A 97 a
• 2 STX (start of text) 34 " 66 B 98 b
• 3 ETX (end of text) 35 # 67 C 99 c
• 4 EOT (end of transmission) 36 $ 68 D 100 d
• 5 ENQ (enquiry) 37 % 69 E 101 e
• 6 ACK (acknowledge) 38 & 70 F 102 f
• 7 BEL (bell) 39 ' 71 G 103 g
• 8 BS (backspace) 40 ( 72 H 104 h
• 9 TAB (horizontal tab) 41 ) 73 I 105 i
• 10 LF (NL line feed, new line) 42 * 74 J 106 j
• 11 VT (vertical tab) 43 + 75 K 107 k
• 12 FF (NP form feed, new page) 44 , 76 L 108 l
• 13 CR (carriage return) 45 - 77 M 109 m
• 14 SO (shift out) 46 . 78 N 110 n
• 15 SI (shift in) 47 / 79 O 111 o
• 16 DLE (data link escape) 48 0 80 P 112 p
• 17 DC1 (device control 1) 49 1 81 Q 113 q
• 18 DC2 (device control 2) 50 2 82 R 114 r
• 19 DC3 (device control 3) 51 3 83 S 115 s
• 20 DC4 (device control 4) 52 4 84 T 116 t
• 21 NAK (negative acknowledge) 53 5 85 U 117 u
• 22 SYN (synchronous idle) 54 6 86 V 118 v
• 23 ETB (end of trans. block) 55 7 87 W 119 w
• 24 CAN (cancel) 56 8 88 X 120 x
• 25 EM (end of medium) 57 9 89 Y 121 y
• 26 SUB (substitute) 58 : 90 Z 122 z
• 27 ESC (escape) 59 ; 91 [ 123 {
• 28 FS (file separator) 60 < 92  124 |
• 29 GS (group separator) 61 = 93 ] 125 }
• 30 RS (record separator) 62 > 94 ^ 126 ~
• 31 US (unit separator) 63 ? 95 _ 127 DEL
Casting of primitive types
byte b = 10;
char c = ‘X’;
int i = 1027;
short s = 258;
// Would you allow the following? Why or why not?
i = b; // copy a byte field into an integer field
b = i; // copy an integer value into a byte field
i = c; // copy a character into an integer field
c = s; // copy a short into a character
c++; // increment a character
c = c + 1; // add 1 to a character

More Related Content

Similar to Java Primitive Types - Understand bytes, chars, ints and more

Similar to Java Primitive Types - Understand bytes, chars, ints and more (20)

Cryptographic algorithms
Cryptographic algorithmsCryptographic algorithms
Cryptographic algorithms
 
Digital Electronics Notes.pdf
Digital Electronics Notes.pdfDigital Electronics Notes.pdf
Digital Electronics Notes.pdf
 
W 9 numbering system
W 9 numbering systemW 9 numbering system
W 9 numbering system
 
W 9 numbering system
W 9 numbering systemW 9 numbering system
W 9 numbering system
 
Number system
Number systemNumber system
Number system
 
2013 1
2013 1 2013 1
2013 1
 
UNIT-1_CSA.pdf
UNIT-1_CSA.pdfUNIT-1_CSA.pdf
UNIT-1_CSA.pdf
 
Digital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfDigital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdf
 
Cit 1101 lec 02
Cit 1101 lec 02Cit 1101 lec 02
Cit 1101 lec 02
 
Okkkkk
OkkkkkOkkkkk
Okkkkk
 
ADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptxADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptx
 
AES.pptx
AES.pptxAES.pptx
AES.pptx
 
Block Encryption Algorithm Project.docx
Block Encryption Algorithm Project.docxBlock Encryption Algorithm Project.docx
Block Encryption Algorithm Project.docx
 
bits.ppt
bits.pptbits.ppt
bits.ppt
 
Materi Program.ppt
Materi Program.pptMateri Program.ppt
Materi Program.ppt
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.ppt
 
Number system by ammar nawab
Number system by ammar nawabNumber system by ammar nawab
Number system by ammar nawab
 
21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx
 
Logic Design - Chapter 1: Number Systems and Codes
Logic Design - Chapter 1: Number Systems and CodesLogic Design - Chapter 1: Number Systems and Codes
Logic Design - Chapter 1: Number Systems and Codes
 
01.number systems
01.number systems01.number systems
01.number systems
 

More from MattMarino13

1-22-24 INFO 2106.pptx
1-22-24 INFO 2106.pptx1-22-24 INFO 2106.pptx
1-22-24 INFO 2106.pptxMattMarino13
 
1-24-24 INFO 3205.pptx
1-24-24 INFO 3205.pptx1-24-24 INFO 3205.pptx
1-24-24 INFO 3205.pptxMattMarino13
 
BITM3730 11-14.pptx
BITM3730 11-14.pptxBITM3730 11-14.pptx
BITM3730 11-14.pptxMattMarino13
 
01_Felke-Morris_Lecture_ppt_ch01.pptx
01_Felke-Morris_Lecture_ppt_ch01.pptx01_Felke-Morris_Lecture_ppt_ch01.pptx
01_Felke-Morris_Lecture_ppt_ch01.pptxMattMarino13
 
02slide_accessible.pptx
02slide_accessible.pptx02slide_accessible.pptx
02slide_accessible.pptxMattMarino13
 
Hoisington_Android_4e_PPT_CH01.pptx
Hoisington_Android_4e_PPT_CH01.pptxHoisington_Android_4e_PPT_CH01.pptx
Hoisington_Android_4e_PPT_CH01.pptxMattMarino13
 
AndroidHTP3_AppA.pptx
AndroidHTP3_AppA.pptxAndroidHTP3_AppA.pptx
AndroidHTP3_AppA.pptxMattMarino13
 
9780357132302_Langley11e_ch1_LEAP.pptx
9780357132302_Langley11e_ch1_LEAP.pptx9780357132302_Langley11e_ch1_LEAP.pptx
9780357132302_Langley11e_ch1_LEAP.pptxMattMarino13
 
krajewski_om12 _01.pptx
krajewski_om12 _01.pptxkrajewski_om12 _01.pptx
krajewski_om12 _01.pptxMattMarino13
 
CapsimOpsIntroPPT.Marino.pptx
CapsimOpsIntroPPT.Marino.pptxCapsimOpsIntroPPT.Marino.pptx
CapsimOpsIntroPPT.Marino.pptxMattMarino13
 
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptxProject Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptxMattMarino13
 
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptxProject Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptxMattMarino13
 
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...MattMarino13
 
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...MattMarino13
 
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...MattMarino13
 
1-23-19 Agenda.pptx
1-23-19 Agenda.pptx1-23-19 Agenda.pptx
1-23-19 Agenda.pptxMattMarino13
 
EDF 8289 Marino PPT.pptx
EDF 8289 Marino PPT.pptxEDF 8289 Marino PPT.pptx
EDF 8289 Marino PPT.pptxMattMarino13
 
Agenda January 20th 2016.pptx
Agenda January 20th 2016.pptxAgenda January 20th 2016.pptx
Agenda January 20th 2016.pptxMattMarino13
 
BITM3730 8-29.pptx
BITM3730 8-29.pptxBITM3730 8-29.pptx
BITM3730 8-29.pptxMattMarino13
 
BITM3730 8-30.pptx
BITM3730 8-30.pptxBITM3730 8-30.pptx
BITM3730 8-30.pptxMattMarino13
 

More from MattMarino13 (20)

1-22-24 INFO 2106.pptx
1-22-24 INFO 2106.pptx1-22-24 INFO 2106.pptx
1-22-24 INFO 2106.pptx
 
1-24-24 INFO 3205.pptx
1-24-24 INFO 3205.pptx1-24-24 INFO 3205.pptx
1-24-24 INFO 3205.pptx
 
BITM3730 11-14.pptx
BITM3730 11-14.pptxBITM3730 11-14.pptx
BITM3730 11-14.pptx
 
01_Felke-Morris_Lecture_ppt_ch01.pptx
01_Felke-Morris_Lecture_ppt_ch01.pptx01_Felke-Morris_Lecture_ppt_ch01.pptx
01_Felke-Morris_Lecture_ppt_ch01.pptx
 
02slide_accessible.pptx
02slide_accessible.pptx02slide_accessible.pptx
02slide_accessible.pptx
 
Hoisington_Android_4e_PPT_CH01.pptx
Hoisington_Android_4e_PPT_CH01.pptxHoisington_Android_4e_PPT_CH01.pptx
Hoisington_Android_4e_PPT_CH01.pptx
 
AndroidHTP3_AppA.pptx
AndroidHTP3_AppA.pptxAndroidHTP3_AppA.pptx
AndroidHTP3_AppA.pptx
 
9780357132302_Langley11e_ch1_LEAP.pptx
9780357132302_Langley11e_ch1_LEAP.pptx9780357132302_Langley11e_ch1_LEAP.pptx
9780357132302_Langley11e_ch1_LEAP.pptx
 
krajewski_om12 _01.pptx
krajewski_om12 _01.pptxkrajewski_om12 _01.pptx
krajewski_om12 _01.pptx
 
CapsimOpsIntroPPT.Marino.pptx
CapsimOpsIntroPPT.Marino.pptxCapsimOpsIntroPPT.Marino.pptx
CapsimOpsIntroPPT.Marino.pptx
 
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptxProject Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
 
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptxProject Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
 
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
 
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
 
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
 
1-23-19 Agenda.pptx
1-23-19 Agenda.pptx1-23-19 Agenda.pptx
1-23-19 Agenda.pptx
 
EDF 8289 Marino PPT.pptx
EDF 8289 Marino PPT.pptxEDF 8289 Marino PPT.pptx
EDF 8289 Marino PPT.pptx
 
Agenda January 20th 2016.pptx
Agenda January 20th 2016.pptxAgenda January 20th 2016.pptx
Agenda January 20th 2016.pptx
 
BITM3730 8-29.pptx
BITM3730 8-29.pptxBITM3730 8-29.pptx
BITM3730 8-29.pptx
 
BITM3730 8-30.pptx
BITM3730 8-30.pptxBITM3730 8-30.pptx
BITM3730 8-30.pptx
 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Java Primitive Types - Understand bytes, chars, ints and more

  • 1. PRIMITIVE TYPES IN JAVA Primitive Types Operations on Primitive Types
  • 2. Review of Binary Numbers • Numbering systems • Counting in Decimal • Counting in Binary • Counting in Hexadecimal
  • 3. Decimal Numbers Decimal Numbers Given 98, what is the next number? 99 Given 99, what is the next number? 100 Why? In decimal, we use ten symbols, 0,1,2,3,4,5,6,7,8,9 When we increment a number, we increase the smallest value by one. If that symbol is already the highest symbol (9 in decimal), we repeatedly set it back to the lowest symbol (0 in all numbering systems) and increment the next symbol.
  • 4. Binary Numbers Binary Numbers Given 010, what is the next number? 011 Given 011, what is the next number? 100 Why? In binary, we use two symbols, 0,1 When we increment a number, we increase the smallest value by one. If that symbol is already the highest symbol (1 in binary), we repeatedly set it back to the lowest symbol (0 in all number systems) and increment the next symbol.
  • 5. Counting from zero to fifteen in binary 0000 zero 0001 one 0010 two 0011 three 0100 four 0101 five 0110 six 0111 seven 1000 eight 1001 nine 1010 ten 1011 eleven 1100 twelve 1101 thirteen 1110 fourteen 1111 fifteen
  • 6. Hexadecimal Numbers Binary Numbers Given 0FE, what is the next number? 0FF Given 0FF, what is the next number? 100 Why? In hexadecimal, we use sixteen symbols, 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F When we increment a number, we increase the smallest value by one. If that symbol is already the highest symbol (F in hexadecimal), we repeatedly set it back to the lowest symbol (0 in all number systems) and increment the next symbol.
  • 7. Relationship between Binary and Hex Since hexadecimal has 16 symbols and in binary 4 bits (binary digits) exactly maps to 16 different values 0000 to 1111 represents zero through fifteen in binary 0 to F represents zero through fifteen in hex Hexadecimal can be thought of as shorthand for binary. Ex) x01FB = b0000 0001 1111 1011
  • 8. Primitive types in Java Type Contains Default Size Min Max boolean true/false false 1bit n/a n/a char Unicode u0000 16 bits u0000 uFFFF byte Signed integer 0 8 bits -128 +127 short Signed integer 0 16 bits -32,768 +32,767 int Signed integer 0 32 bits -2 Gig +2 Gig -1 long Signed Integer 0 64 bits - Huge + Huge float IEEE 754 float 0.0 32 bits - Large + Large double IEEE 754 float 0.0 64 bits - Huge + Huge Note: 8 bits can represent xFF = 256 numbers 16 bits can represent xFFFF = 65,532 numbers = 64 K 32 bits can represent XFFFF FFFF = 4,294,967,296 numbers = 4 Gig
  • 9. JAVA character codes • Dec Char Dec Char Dec Char Dec Char • --------- --------- --------- ---------- • 0 NUL (null) 32 SPACE 64 @ 96 ` • 1 SOH (start of heading) 33 ! 65 A 97 a • 2 STX (start of text) 34 " 66 B 98 b • 3 ETX (end of text) 35 # 67 C 99 c • 4 EOT (end of transmission) 36 $ 68 D 100 d • 5 ENQ (enquiry) 37 % 69 E 101 e • 6 ACK (acknowledge) 38 & 70 F 102 f • 7 BEL (bell) 39 ' 71 G 103 g • 8 BS (backspace) 40 ( 72 H 104 h • 9 TAB (horizontal tab) 41 ) 73 I 105 i • 10 LF (NL line feed, new line) 42 * 74 J 106 j • 11 VT (vertical tab) 43 + 75 K 107 k • 12 FF (NP form feed, new page) 44 , 76 L 108 l • 13 CR (carriage return) 45 - 77 M 109 m • 14 SO (shift out) 46 . 78 N 110 n • 15 SI (shift in) 47 / 79 O 111 o • 16 DLE (data link escape) 48 0 80 P 112 p • 17 DC1 (device control 1) 49 1 81 Q 113 q • 18 DC2 (device control 2) 50 2 82 R 114 r • 19 DC3 (device control 3) 51 3 83 S 115 s • 20 DC4 (device control 4) 52 4 84 T 116 t • 21 NAK (negative acknowledge) 53 5 85 U 117 u • 22 SYN (synchronous idle) 54 6 86 V 118 v • 23 ETB (end of trans. block) 55 7 87 W 119 w • 24 CAN (cancel) 56 8 88 X 120 x • 25 EM (end of medium) 57 9 89 Y 121 y • 26 SUB (substitute) 58 : 90 Z 122 z • 27 ESC (escape) 59 ; 91 [ 123 { • 28 FS (file separator) 60 < 92 124 | • 29 GS (group separator) 61 = 93 ] 125 } • 30 RS (record separator) 62 > 94 ^ 126 ~ • 31 US (unit separator) 63 ? 95 _ 127 DEL
  • 10. Casting of primitive types byte b = 10; char c = ‘X’; int i = 1027; short s = 258; // Would you allow the following? Why or why not? i = b; // copy a byte field into an integer field b = i; // copy an integer value into a byte field i = c; // copy a character into an integer field c = s; // copy a short into a character c++; // increment a character c = c + 1; // add 1 to a character