Online Programming Server

Login

Login with facebook [?]

Facebook

Tutorial 44: CSC1130S - Lecture 2b: More about Primitive Types and Operators

You are here: Tutorials >> Basic >> Java >> Introduction to Computing Using Java >> CSC1130S - Lecture 2b: More about Primitive Types and Operators

Tutorial ID44
TitleCSC1130S - Lecture 2b: More about Primitive Types and Operators

Default Type of Floating-point Number Literals

  • Floating-point Number literals are considered to be of type double by default.
double d1 = 3.14159;	// ok
double d2 = 3e8;		// ok
double d3 = -0.27e-5;	// ok
float  f1 = 3.14159;	// not ok
  • Adding a suffix F / f to the number changes this default:
float  f2 = 3.14159F;	// ok
float  f3 = -0.27e-5f;	// ok

Post Your Comment

Title
Message