refer to ivor horton’s beginning ansi c++ the complete language, 3rd ed. apress media, llc. more...

Download Refer to Ivor Horton’s Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. More on Handling Basic Data Types Mixed types of data Data

If you can't read please download the document

Upload: amice-walker

Post on 18-Jan-2018

222 views

Category:

Documents


0 download

DESCRIPTION

Refer to Ivor Horton’s Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Explicit Casts Static cast –Old-style casts (C) (object_type) (expression) int a = (int) 3.5; or int a = 3.5; –New-style casts (C++) static_cast (expression) int a = static_cast 3.5*23; Program 3.1

TRANSCRIPT

Refer to Ivor Hortons Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. More on Handling Basic Data Types Mixed types of data Data type conversion Bitwise operators Define a new type Define alternative names for existing data types Variables duration and scope Refer to Ivor Hortons Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Mixed expressions Mixed expression rule Two floating operation higher precision Floating and Integer operation floating See details in p.92 Refer to Ivor Hortons Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Explicit Casts Static cast Old-style casts (C) (object_type) (expression) int a = (int) 3.5; or int a = 3.5; New-style casts (C++) static_cast (expression) int a = static_cast 3.5*23; Program 3.1 Refer to Ivor Hortons Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. sizeof() Count the size of a type or a variable Program 3.2 Refer to Ivor Hortons Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Numeric Limitation numeric_limits ::min() numeric_limits ::max() numeric_limits ::digits Program 3.3 Header file limits.h Refer to Ivor Hortons Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Boolean Operators T: true; F: false PQP && QP || Q!P TTTTF TFFTF FTFTT FFFFT Refer to Ivor Hortons Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Bitwise operators Bitwise operations bit1bit2&|^~bit : true, 0: false Refer to Ivor Hortons Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Bitwise Operators Bitwise AND & 0&0 0 0&1 0 1&1 1 Bitwise OR | 0|0 0 0|1 1 1|1 1 Bitwise XOR ^ 0^0 0 0^1 1 1^1 0 Left shift >2 ( ) Bitwise complement ~ ~( ) ( ) Refer to Ivor Hortons Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Bitwise exclusive OR operations Program 3.4 Refer to Ivor Hortons Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Bitwise exclusive OR operations Program 3.4 Refer to Ivor Hortons Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Number System 0x1AF = 1* * = 431 0xCAD = 12* * = 3245 o123 = 1*8 2 +2* = 83 o10101 = 1*8 4 +0*8 3 +1*8 2 +0* = x1AF = ( ) = o717 o123 = ( ) = 0x53 Refer to Ivor Hortons Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Output Manipulators Header file iostream.h Behind cout