Jump to content

please see into the matter

- - - - -

  • Please log in to reply
6 replies to this topic

#1
novera_monkey

novera_monkey

    Newbie

  • Members
  • Pip
  • 2 posts
how to save a long long int (64 bit) in simply an int ?
i.e and int inputs values tht are very long and save them and then we have to multiply those values from one another.
we cannot use long from it , i.e we have to combine two 32 bit int to make a 64 bit .
we can use classes.

#2
artificial

artificial

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 624 posts
So, you aren't allowed to use "long long", right? You could use a struct instead that consists of two 32-bit integers.

struct MyInt64

{

  long nHighOrderQW; //QW = Quadword = 32 bit

  long nLowOrderQW;

};


Simply ask if there are more questions.

Greets,
artificial

Edited by artificial, 15 July 2010 - 02:38 AM.

Sometimes words ain't enough to express something. That's why computer scientists use double words.

#3
novera_monkey

novera_monkey

    Newbie

  • Members
  • Pip
  • 2 posts
what further ?
how will we carry on with the program , please help me it it!!

#4
Ancient Dragon

Ancient Dragon

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 400 posts
Same question posted on DaniWeb.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.

#5
zoranh

zoranh

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts

artificial said:

So, you aren't allowed to use "long long", right? You could use a struct instead that consists of two 32-bit integers.
struct MyInt64
{
  long nHighOrderQW; //QW = Quadword = 32 bit
  long nLowOrderQW;
};

Simply ask if there are more questions.

Greets,
artificial
Lower part must be unsigned long or won't work. In this way you've lost one bit of information from original 64-bit signed integer - it had 63 bits of numeric information plus one bit for sign, while two longs have 62 bits of numeric information and two sign bits.

#6
TkTech

TkTech

    The Crazy One

  • Moderators
  • 1,396 posts
This appears to be a homework question.

@Op: I'd advise you to look into arbitrary precision arithmetic. In particular, look at the theory and a very good example on LiteratePrograms.

#7
artificial

artificial

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 624 posts

zoranh said:

Lower part must be unsigned long or won't work.

Oh, yes, you're right. My bad. :)
Sometimes words ain't enough to express something. That's why computer scientists use double words.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users