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

  • Home
  • SEARCH
  • 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

The XML String I am getting from other application is converting & to &
From this code: int x = 5; int other = 10; vector<int*> v_ptr; v_ptr.push_back(&x);
Here is a sample from Kernighan & Ritchie's The C Programming Language: int getline(char
Below is a question from Kathy & Bert Bates SCJP 5 preparation CD. I
While solving exercises from the K&R C book, I stumbled upon the exercise 2.1.
I am fetching data from some tables & storing it in a variable like
From http://projecteuler.net/index.php?section=problems&id=99 Comparing two numbers written in index form like 2 11 and 3
I created an AMP web application that was originally going to be served from
Since Graduating from a very small school in 2006 with a badly shaped &
I'm implementing drag & drop from a ListBox, but I'm seeing some strange behaviour

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.