Floating-point Types
Floating-point Types
Examples of Floating-point Declarations
•May
be in scientific notation with an exponent
•n.ne±P
–3.2e+5 is equivalent to 320,000
–1.76e-3 is equivalent to .00176
•OR in
standard decimal notation
•Default
type is double
Examples of Floating-point Declarations
double extraPerson
= 3.50; // extraPerson originally
set
// to 3.50
double averageScore
= 70.0; // averageScore originally set
// to 70.0
double priceOfTicket; // cost of a movie
ticket
double gradePointAverage; // grade point average
float totalAmount
= 23.57f; // note the f must be placed after
// the value for float types
Comments
Post a Comment