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 7083239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:09:13+00:00 2026-05-28T07:09:13+00:00

From k&R C First, if either operand is long double, the other is converted

  • 0

From k&R C

  • First, if either operand is long double, the other is converted to long double.
  • Otherwise, if either operand is double, the other is converted to double.
  • Otherwise, if either operand is float, the other is converted to float.
  • Otherwise, the integral promotions are performed on both operands;
    …

This would mean below expression

char a,b,c;

c=a+b;

is actually caculated as

c = char((int)a+(int)b);

What is the rationale behind this rule?

Do these conversions happen if a, b and c were short ?

  • 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-28T07:09:14+00:00Added an answer on May 28, 2026 at 7:09 am

    No that’s not actually true. C99 Section 5.1.2.3 Program execution, clause 10 covers exactly the case you ask about:

    EXAMPLE 2
    In executing the fragment
    char c1, c2;
    c1 = c1 + c2;
    the “integer promotions” require that the abstract machine promote the value of each variable to int size and then add the two ints and truncate the sum.

    Provided the addition of two chars can be done without overflow, or with overflow wrapping silently to produce the correct result, the actual execution need only produce the same result, possibly omitting the promotions.

    So, if the operation is known to produce the same result, there’s no requirement for using the wider values.

    But if you want the rationale behind a specific decision made in the standard, you have to look at, ….. wait for it, ….. yes, the Rationale document 🙂

    In section 6.3.1.8 of that rationale (sections match those in the standard), it states:

    Explicit license was added to perform calculations in a “wider” type than absolutely necessary, since this can sometimes produce smaller and faster code, not to mention the correct answer more often.

    Calculations can also be performed in a “narrower” type by the as if rule so long as the same end result is obtained.

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

Sidebar

Related Questions

I have an overloaded << operator from my reckful class implemented as follows: ostream&
Note that the order can go either way (erase first then push back, just
What I'm trying to do is play the first video retrieved from the external
I've got the following code: SELECT ItemName FROM skuDetails WHERE skuDetails.SkuNumber = ' &
First off, either A) I'm not investigating into this hard enough or B) I've
I have a data table populated from a MySQL database via PHP. The first
I have the task of migrating my team & source from git to Perforce,
Long time stackoverflow reader, first time poster. Forgive me if I'm not asking a
I'm importing ~18,000 records of various entities that are related to each other from
I am rendering audio waveforms directly from MP3's on the fly as they are

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.