473,322 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Arithmatic in c

Hi All,

I want to do arithmetic in c like below:

A Op B = C
1. 0x1100 Op 0x1000 = 0x0100
2. 0x2300 Op 0x1000 = 0x0300
3. 0x1000 Op ox1000 = 0x1000

I know if I do A%B then I can get C. But it is true only for case 1 and 2. But in case 3 A%B will give 0x0000.

I want to perform same operation on A and B to get C in all cases.

If it is not possible by single operator i don't mind doing multiple operations on A and B to get C.

Please help me in this.

Hope my question make sense.

Regards,
Kiran
Sep 28 '10 #1
2 1851
weaknessforcats
9,208 Expert Mod 8TB
0x1000 % 0x1000 = 0x1000

This is correct since the remainder of 0x1000/0x1000 is
0x0000.

All of your cases work using the % operator.
Sep 28 '10 #2
donbock
2,426 Expert 2GB
@weaknessforcats:
x % x = 0 for (x != 0).

@kiran:
Where did this problem come from? Are you sure you copied case 3 accurately?
Sep 28 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: David Morris | last post by:
OK, this is for you experienced Java programmers out there. I have a string that contains the following value: "myValue += 5" I need, in Java, to be able to evaluate this expression. ...
0
by: faheem via .NET 247 | last post by:
From: faheem wattoo I am have the same as above listed problemof System.ArithmaticOperation from last 3 months instead of repateding 5 freshinstallation.some times it runs well on the first...
11
by: junky_fellow | last post by:
Can I subtract two pointers of same type that are pointing to the two different location of memory allocated by malloc. eg. #include <stdlib.h> int main(void) { unsigned char *c_ptr;...
9
by: Harry | last post by:
Hi, I wonder whether anyone could help me to do a maths calculation? I have three boxes which take numeric values double PPrice = Convert.ToDouble(txtPurchasePrice.Text); double BCost =...
7
by: Daz | last post by:
Hi everyone. I am a little confused and frustrated as to how the maximum lengths for integers and floating point numbers came about, and whilst you shouldn't need a number bigger than...
2
by: sapnakiran | last post by:
Can u tell me how can we build up arithmatic operation without using arithmatic operator
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.