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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:14:24+00:00 2026-05-14T14:14:24+00:00

If I do double d = 34.56; int i = (int)d; Am I not

  • 0

If I do

double d = 34.56;
int i = (int)d;

Am I not “downcasting”?

OR

Is this term only used in terms of classes and objects?


I am confused because in this case we are “downcasting” from a bigger double to a smaller int, but in case of classes, we “downcast” from a smaller base class to a bigger derived class.

Aren’t these two conventions, in some sense, opposite?

  • 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-14T14:14:24+00:00Added an answer on May 14, 2026 at 2:14 pm

    No, you are not down casting. You are just casting, and you’re chopping off anything after the decimal.

    Down casting doesn’t apply here. The primitives int and double are not objects in C++ and are not related to each other in the way two objects in a class hierarchy are. They are separate and primitive entities.

    Down casting refers to the act of casting one object into another object that derives from it. It refers to the act of moving down from the root of the class hierarchy. It has nothing to do with the sizes of types in question.

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

Sidebar

Related Questions

I use operator() as a subscript operator this way: double CVector::operator() (int i) const
This errors: double z; int? x = 0; int? y = 0; z =
I wrote this code: public double SumRootN(int root) { double result = 0; for
The following c++ code does not compile: int main() { double a = abs(5.1);
I have two questions regarding this code. What does the double*** pdata and int***
Let's say I have interface IMatrix { double this[int r, int c] { get;
Why for table like this: create table tbl ( id int not null auto_increment,
I have a table like this CREATE TABLE values ( id int(10) auto_increment NOT
My code: def power(x: Double, n: Int): Double = { if (n % 2
I'm reading some C code like that: double function( int lena,double xa,double ya, double

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.