473,666 Members | 2,386 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;
  3.  
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;
  3.  
  4.  $tmp2_dec = hex($tmp);
  5.  $tmp3_dec = hex($tmp1);
  6.  
  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);
  11.  
  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. }
  17.  
Thanks
Raghavendra
Nov 1 '08 #1
5 6388
KevinADC
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 .

http://perldoc.perl.org/functions/oct.html
Nov 1 '08 #2
raghavendrap
19 New Member
Hello,
Can you please be clear about what your are trying to explain me.



Thanks
Raghavendra
Nov 3 '08 #3
KevinADC
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');
  3.  
  4. print "$tmp2_dec   $tmp3_dec\n";
  5.  
  6. $t2 = sprintf "%d", $tmp2_dec;
  7. $t3 = sprintf "%d", $tmp3_dec;
  8.  
  9. print "$t2 $t3\n";
  10.  
  11. printf ("Decimal Value tmp is %d \n",$tmp2_dec);
  12. printf("Decimal Value tmp1 is %d \n",$tmp3_dec);
  13.  
  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
raghavendrap
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..

Thanks
Raghvendra
Nov 4 '08 #5

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

Similar topics

8
27196
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 machine-dependent?
38
11138
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 textbox1 and textbox2 and multiply them together. Th result - displays in textbox 3 I think I'm...
25
6247
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;
9
8617
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.
15
35482
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??
40
2791
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 in writing C programs that are free from common integer problems such as integer overflow, integer...
13
3210
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
42
7004
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 setjmp(), longjmp() in C) for integer
6
4991
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 types of undetermined size and no really optimal way to even build a variable width number library...
0
8362
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,...
0
8785
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8560
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,...
0
8644
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7389
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5671
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
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
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
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

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.