The ios::uppercase flag to display scientific notation-exponents and hexadecimal values in uppercase C++ code sample

 

Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows XP Pro SP2

Header file: Standard

Additional library: none/default

Additional project setting: Set project to be compiled as C++

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C++ Code (/TP)

Other info: none

To do: Using ios::uppercase flag to display scientific notation-exponents and hexadecimal values in uppercase C++ code sample

To show: How to use the C++ ios::uppercase flag to display scientific notation-exponents and hexadecimal values in uppercase in C++ programming

 

// using the ios::uppercase flag

#include <iostream>

#include <iomanip>

using namespace std;

 

void main(void)

{

long p = 12345678;

 

// The numbers are displayed with digits a through f in lower case if the uppercase flag is clear (the default);

// otherwise, they are displayed in upper case and the default radix is dec (decimal).

cout<<setiosflags(ios::uppercase)

<<"Uppercase letters in scientific\n"

<<"notation-exponents and hexadecimal values:\n"

<<"------------------------------------------\n"

<<5.7654e12<<'\n'

<<hex<<p<<endl;

}

 

Output example:

 

Uppercase letters in scientific

notation-exponents and hexadecimal values:

------------------------------------------

5.7654E+012

BC614E

Press any key to continue . . .

 

 

C and C++ Programming Resources | C & C++ Code Example Index