473,807 Members | 2,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hexa Decimal Addition in C

2 New Member
Hi friends, I want to write a program to add two hexa-decimal numbers. I know there is no way of direction addtion. My logic is, first convert two hexa-numbers into decimal after that we add and finally we have to convert the resultant decimal into hexadecimal. Is it right? Give your suggestion.
Dec 2 '06 #1
2 3700
DeMan
1,806 Top Contributor
I may be wrong, but I know hexadecimal numbers can be decalred 0x0f45 (for example, and stored as integers so I would imagine you can add them and do all sorts of things. I'm pretty sure when you are using printf to print to the screen, you can manipulate %d to display hexadecimal values
Dec 2 '06 #2
horace1
1,510 Recognized Expert Top Contributor
Hi friends, I want to write a program to add two hexa-decimal numbers. I know there is no way of direction addtion. My logic is, first convert two hexa-numbers into decimal after that we add and finally we have to convert the resultant decimal into hexadecimal. Is it right? Give your suggestion.
information is stored within the computer in binary and converted into decimal, octal or hex notation when we input and output numeric data. e.g. in to print a value in hex
Expand|Select|Wrap|Line Numbers
  1.     int i=0x02F4B;
  2.     printf("i in hex %#0x\n", i);
  3.  
and in C++
Expand|Select|Wrap|Line Numbers
  1.     int i=0x02F4B;
  2.     cout << "i in hex " << setiosflags(ios::showbase) << hex << i  << endl;
  3.  
when run both give
i in hex 0x2f4b

similar conversion is used to input data in hex
Dec 2 '06 #3

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

Similar topics

17
6159
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number. "Decimal Number" sometimes serves to distinguish Base 10 numbers, eg "15", from Base 2 numbers, Eg "1111". At other times "Decimal Number" serves to differentiate a number from an integer. For the rest of this post I shall only use either...
4
5268
by: Dany | last post by:
Hi When I open an Hexa file I have some weird char like when I open it with Notepad. I want to open it in a readeable form (ex: "FF25AB") like with Ultra edit. Thanks regards, Dany
1
11743
by: Adam | last post by:
Hello, I'm trying to decifer the data in the table that stores the data in the binary format. All numbers are placed in varbinary fields. All I know is the MS SQL 2000 database useing collation SQL_Latin1_General_CP1_CI_AS (default). For example the content of the field is: (0xB4F5000000000000) in unicode and defined as varbinary(8).
3
6897
by: Golan | last post by:
Hello, I have a hexa file which I need to convert to decimal. I use memcpy into variables (char for one octet, short for 2 octets and int for 4 octets) and then print the value into the file by using fprintf. The problem is that I don't know how to convert a field of 6 octets? Should I use a long variable? Thanks
2
17048
by: Nadav | last post by:
Hi, How can I use C# to print a number in hexadecimal e.g. printf(" %x "); or print 15 ( decimal ) as 'F' (hexa) Can a number be printed as binary as-well? Thanks in advance, Nadav.
1
2118
by: Chandra | last post by:
Hi, I have a problem related to File Reading. I have a file which contains data which is in Hexa format. I have to read that data and push it to a function which takes a parameter of type char. I am able to read the data from the file, which i am getting as characters. For example: Suppose the Hexa value from the File data is ABCDEFGH. In hexa form 0xAB is one byte. So, while reading this data A is taken as a byte which is not a...
2
3154
by: mshahzadali | last post by:
is there any expert who could guide me making a C++ program. I want to convert a Decimal number into a Binary, Octal and a Hexadecimal Number using a C++ Built-in Function(if there exist any).
5
2367
by: lokeshrajoria | last post by:
hello, how to convert binary to hexa decimal..... thanks & regards lokiiiii
12
2176
by: Frank Millman | last post by:
Hi all I have a standard requirement for a 'decimal' type, to instantiate and manipulate numeric data that is stored in a database. I came up with a solution long before the introduction of the Decimal type, which has been working well for me. I know the 'scale' (number of decimal places) of the number in advance. When I read the number in from the database I scale it up to an integer. When I write it back I scale it down again. All...
0
9720
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3854
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.