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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:26:33+00:00 2026-06-07T13:26:33+00:00

I have following structure struct { int myData; int myAnotherData; }Value; struct AnotherStructure {

  • 0

I have following structure

struct {
    int myData;
    int myAnotherData;
}Value;

struct AnotherStructure {
    unsigned int uiLowData;
    unsigned int uiHighData;
};

AnotherStructure m_AnotherStructure;
Value val;
val.myData = 10;
#define MULTIPLY 36000000000

unsigned __int64 &internalStructure = *(unsigned __int64*)&m_AnotherStructure;
internalStructure  = 0;
internalStructure += ((unsigned __int64)val.myData * MULTIPLY );

My questions is there any overflow of data in above case as we are multiplying unsigned int with big value, is result stored in temp value of type unsigned int and then stored in int 64? If now how there won’t be any overflow?

Thanks

  • 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-06-07T13:26:35+00:00Added an answer on June 7, 2026 at 1:26 pm

    val.myData is casted to unsigned __int64 before the multiplication, because you explicitly cast.
    still overflows can occur, depending on the value stored in val.myData – the maximum int multiplied by 36000000000 wont fit into 64 bits.
    and you loose your algebraic sign with the cast.

    you should try this:

    struct AnotherStructure {
        int64_t uiLowData;
        int64_t uiHighData;
    };
    // signed_128bit_integer: look into your compiler documentation
    signed_128bit_integer &internalStructure = *(signed_128bit_integer*)&m_AnotherStructure;
    internalStructure  = 0;
    internalStructure += ((signed_128bit_integer)val.myData * MULTIPLY );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

gcc 4.4.4 c89 I have the following structure. struct device_sys { char device[STRING_SIZE]; int
Say we have the following structure: struct Tree { string id; int numof_children; Tree
I have the following template structure: template <typename scalar_type> struct postc_params{ scalar_type delta; unsigned
Hi I have the following scenario #define CONSTANT 10 struct structA{ int var1; int
I have the following structure in c++: #define CGAPI_Exports_Attr __declspec(dllimport) extern CCGAPI_Exports_Attr struct PointCg
I have the following structure: private struct S_indiv { public int[] x; public int
I have the following structure: struct CountCarrier { int *CurrCount; }; And this is
I have the following structure: [StructLayout(LayoutKind.Sequential)] public struct TCurve { public int fNumItems; /*
I have a structure of the following type struct Node { int word; int
Assume we have a simple structure such as the following struct T{ int x;

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.