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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:10:10+00:00 2026-05-17T22:10:10+00:00

If I do: int i=3, j=10; float f; f=(i+j)/2; so f won’t get value

  • 0

If I do:

int i=3, j=10;
float f;
f=(i+j)/2;
so f won't get value 6.5 but 6.

But,

f=(i+(float)j)/10;//edited 

would be f=6.5.
What is the place where this temporary values are stored and why do we need to type-cast?

  • 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-17T22:10:10+00:00Added an answer on May 17, 2026 at 10:10 pm
    f=(i+j(float))/10;
    

    is incorrect; the type in a cast comes before its operand:

    f=(i+(float)j)/10;
    

    Anyway. When evaluating an arithmetic operator, if one operand is of a floating point type and the other is of an integer type, then the integer operand is converted to the floating point type and floating arithmetic is performed.

    This is part of what are called the usual arithmetic conversions (you can find out more about those by searching Google, though MSDN has a simple explanation of what they are).

    Where the temporary value is stored depends on the compiler and the computer. It’s likely to be stored in a register since you’re going to use it immediately, but it could be stored on the stack or somewhere else.

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

Sidebar

Related Questions

I want to get table metadata for all table columns. Like type string(varchar2)/int/float/datetime and
Consider this program int main() { float f = 11.22; double d = 44.55;
Can someone explain why this doesn't work? int main() { float* x; float a,
Suppose I would like to round up float to int in Java . For
Why is this boost::lambda expression not working? boost::function<bool (boost::uint64_t, boost::uint64_t&, unsigned int, float)> myFunct
I would like to do something like this (I'm aware that this won't compile):
I have an int and float array of length 220 million (fixed). Now, I
I have an int and float array each of length 220 million (fixed). Now,
class Test { public: SOMETHING DoIt(int a) { float FLOAT = 1.2; int INT
Let us suppose i have these three methods defined: int F1(int, int); int F1(float,

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.