Publish On: 2019-03-19

Guy white

Total Post: 819

Question: What is a defining float and double variables

Reply On: 2015-10-14


Total Post: 0

ANS: What is a defining float and double variables

In float type : the value are in fractional type. ex 5.34

Range Rover Hire Service
Reply On: 2013-10-19

Computer Science

Total Post: 1

ANS: What is a defining float and double variables

Float and double data types represent real numbers.

(i) The letter E or e, indicates scientific notation

(ii) The suffix F or f, indicates a float literal

(iii) The suffix D or d, indicates a double literal

(iv) Non suffix floating-pointing literal is double by default

Thus to declare a float, you need to do thus:

Flat fNum = 1.2345F;

This signifies to the compiler that the literal is a float value and not a double. If you were to declare it as:

Float fNum = 1.2345, you will get a compile-time error as

“Possible loss of precision, required float found double.”

A double can be declared as follows:

Double d1 = 123.4;

Double PI = 3.14159D;

Floating-pointing literals can also be specified in scientific notation, for example, 9.87654e+2, which is the same as 9.87654e2 is equivalent to 987.654, and 1.23456e-2 is equivalent to 0.0123456.E (or e) represents an exponent and it can be either in lowercase or uppercase.


Submit Your Answer

warning: Please Login To Submit Your Answer
Like Us On Facebook for All Latest Updates