Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

floating point
c

What is the floating constant in C?

Sarvech Qadir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The floating-point constant is a double-precision floating-point number represented by two numbers separated by an E.

The value of the constant is the product of the first number and the power of 10 specified by the second number.

Types of floating-point constants

  1. Float
  2. Double
  3. Long Double

Criteria

The floating-point constant adheres to the following criteria:

  1. Decimal integer

  2. Decimal point

  3. Decimal fraction

  4. e or E and a signed integer exponent (optional)

  5. Type suffix: f or F or l or L (optional). Example: 0.32f where f denotes float. Also, for example 0.32l, where l denotes long double.

There should be a decimal integer or a fraction – but not both – to qualify for a floating-point constant.

Use prefixed operator minus (-) for negative floating constants.

Constant must be within 24 characters long.

The first number should be within 17 digits, and the exponent must be within 3 digits.

Range

The floating-point constants range from (±2.2250 * 10^-308) to (±6.80564774407 * 10^38).

A user can make use of the l or L suffix, making the constant a long double type if the required number exceeds the given range.

RELATED TAGS

floating point
c

CONTRIBUTOR

Sarvech Qadir
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring