473,573 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to manipulate integer overflow in hexadecimal.(Ur gent)

19 New Member
Expand|Select|Wrap|Line Numbers
  1. $tmp  = 0xc0211082;
  2.  $tmp1 = 0xc0000082;
Hello friends,
I got doubt when i am converting negative hexadecimal to a decimal number.Please look at mentioned example below.
In the below example my question is when i am converting an hexadecimal to an decimal number i am getting integer overflow in hexadecimal? But the actual values of $tmp & $tmp1 in decimal is signed numbers i.e -1071574910,-1073741694 respectively.
How to manipulate this type of situations?
Expand|Select|Wrap|Line Numbers
  1.  $tmp  = 0xc0211082;
  2.  $tmp1 = 0xc0000082;
  4.  $tmp2_dec = hex($tmp);
  5.  $tmp3_dec = hex($tmp1);
  7.  printf("Decimal Value tmp is %d \n",$tmp);
  8.  printf("Decimal Value tmp1 is %d \n",$tmp1);
  9.  printf("Decimal Value tmp2 is %d \n",$tmp2_dec);
  10.  printf("Decimal Value tmp3 is %d \n",$tmp3_dec);
  12. if($tmp2_dec >0 && $tmp3_dec >0){
  13. print("Temporary values are greater than Zero \n");
  14. }else {
  15. print("Temporary values are less than zero \n");
  16. }
Nov 1 '08 #1
5 6384
4,059 Recognized Expert Specialist
As the hex() functions manpage explains:

To convert strings that might start with either 0, 0x, or 0b, see oct .

Nov 1 '08 #2
19 New Member
Can you please be clear about what your are trying to explain me.

Nov 3 '08 #3
4,059 Recognized Expert Specialist
please read the links next time:

Expand|Select|Wrap|Line Numbers
  1. $tmp2_dec = oct('0xc0211082');
  2. $tmp3_dec = oct('0xc0000082');
  4. print "$tmp2_dec   $tmp3_dec\n";
  6. $t2 = sprintf "%d", $tmp2_dec;
  7. $t3 = sprintf "%d", $tmp3_dec;
  9. print "$t2 $t3\n";
  11. printf ("Decimal Value tmp is %d \n",$tmp2_dec);
  12. printf("Decimal Value tmp1 is %d \n",$tmp3_dec);
  14. if($t2 > 0 && $t3 > 0){
  15.    print("Temporary values $t2 and $t3 are greater than Zero \n");
  16. }else {
  17.    print("Temporary values $t2 and $t3 are less than zero \n");
  18. }
Nov 3 '08 #4
19 New Member
Thank you very much kevin
Can u please provide me some useful links of perl, i need to write automation script for assembly instructions & need to generate .asm file..

Nov 4 '08 #5

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

Similar topics

by: Tom Goulet | last post by:
Hello, My question basically is: What is the opposite of the following? | "%08X" % -1 I want to convert a string of hexadecimal characters to the signed integer they would have been before the <print> statement converted them. How do I do this in such a way that is compatible with Python versions 1.5.2 through 2.4, and not...
by: Keith | last post by:
I've been reading and looking on the internet - but I just can't fin this. Perhaps I'm approaching this the wrong way - code-wise I'm attempting to learn how "things" work in VBNET by creating small app - 3 textbox objects. I want the user to input data int textbox1 and textbox2 - and then click on a button - which will tak the values to...
by: junky_fellow | last post by:
Is there any way by which the overflow during addition of two integers may be detected ? eg. suppose we have three unsigned integers, a ,b, c. we are doing a check like if ((a +b) > c) do something;
by: Chris Botha | last post by:
Hi, I have an UInt32 and want to stick the value into an Integer and get an Overflow exception, BUT using C# the same value can be casted into an int and the value is as expected. The Hex value is FFFFFFDB, which should be -37. Thanks.
by: jaks.maths | last post by:
How to convert negative integer to hexadecimal or octal number? Ex: -568 What is the equivalent hexadecimal and octal number??
by: Robert Seacord | last post by:
The CERT/CC has released a beta version of a secure integer library for the C Programming Language. The library is available for download from the CERT/CC Secure Coding Initiative web page at: http://www.cert.org/secure-coding/ The purpose of this library is to provide a collection of utility functions that can assist software developers...
by: Freaker85 | last post by:
Hello, I am new at programming in C and I am searching a manner to parse a string into an integer. I know how to do it in Java, but that doesn't work in C ;o) I searched the internet but I didn't found it yet. help please thank you Freaker85
by: thomas.mertes | last post by:
Is it possible to use some C or compiler extension to catch integer overflow? The situation is as follows: I use C as target language for compiled Seed7 programs. For integer computions the C type 'long' is used. That way native C speed can be reached. Now I want to experiment with raising a Seed7 exception (which is emulated with...
by: Chris Becke | last post by:
I *know* my CPU has opcodes that can do this - when adding (or subtracting) there is a carry flag that can be invoked to make the result essentially 1 bit longer than the data size used in calculations. When multiplying two numbers, the CPU automatically returns a double width result. c & c++ give programmers these bloody ridiculous integer...
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...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
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...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
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...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.