Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6080595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:04:46+00:00 2026-05-23T11:04:46+00:00

In C programming language, the floating point constant is double type by default so

  • 0

In C programming language, the floating point constant is double type by default
so 3.1415 is double type, unless use ‘f’ or ‘F’ suffix to indicate float type.

I assume const float pi = 3.1415 will cause a warning, but actually not.

when I try these under gcc with -Wall:

float f = 3.1415926;  
double d = 3.1415926;  
printf("f: %f\n", f);  
printf("d: %f\n", d);  
f = 3.1415926f;  
printf("f: %f\n", f);  
int i = 3.1415926;  
printf("i: %d\n", i);  

the result is:

f: 3.141593  
d: 3.141593  
f: 3.141593  
i: 3

the result (including double variable) obviously lose precision, but compile without any warning.
so what did the compiler do with this? or did I misunderstand something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:04:47+00:00Added an answer on May 23, 2026 at 11:04 am

    -Wall does not enable warnings about loss of precision, truncation of values, etc. because these warnings are annoying noise and “fixing” them requires cluttering correct code with heaps of ugly casts. If you want warnings of this nature you need to enable them explicitly.

    Also, your use of printf has nothing to do with the precision of the actual variables, just the precision printf is printing at, which defaults to 6 places after the decimal point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which programming language and tools can i use, to develope a complete stand-alone gui-application?
In any programming language, is the type of referencing environment dependent on the scoping?
what programming language/languages do they use to produce games lik Bioware's Dragon Age Origins
Is it a good idea to use IEEE754 floating point NaN (not-a-number) for values
Many programming language runtime environments use stacks as their primary storage structure (e.g. see
Why would a programming language want to use weak typing over strong typing?
What is a dataflow programming language? Why use it? And are there any benefits
I wonder which - programming language - platform - db type - host provider/
Which programming language(s) were used to code Windows Vista?
Which programming language would you recommend to learn about data structures and algorithms in?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.