473,386 Members | 1,693 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,386 software developers and data experts.

SIGNED does not allow negative values???

Hi!

I'm developing for many years, by i have never encountered such problem in
VC++!
I tried doing the simplest test:
Create new solution -Win32 project...

In the main procedure I wrote this:
int i=-1;

And breakpoint on the next line.

The value of i is 0xffffff !!!

I tried writing singed int, the same thing happens..
Tried all of the data types, nada.

Can anyone explain this???
Apr 19 '07 #1
2 1069
I'm developing for many years, by i have never encountered such problem in
VC++!
I tried doing the simplest test:
Create new solution -Win32 project...

In the main procedure I wrote this:
int i=-1;

And breakpoint on the next line.

The value of i is 0xffffff !!!

I tried writing singed int, the same thing happens..
Tried all of the data types, nada.

Can anyone explain this???
Yes.
You display debug information in HEX. The hex for -1 is 0xFFFFFFFF in 2's
complement.
Turn of HEX display for your debug information (e.g. from within the watch
window) and you should be fine.

Kind regards,
Bruno van Dooren MVP - VC++
http://msmvps.com/blogs/vanDooren
Apr 19 '07 #2
You misunderstood...
I wrote 0xffffff so it is more readable than 16777215...
I already checked the values in decimal view...

The problem appears to be something with too loaded memory :-D
After a restart, everything went back to normal...

Thanks anyway!

"Bruno van Dooren" wrote:
I'm developing for many years, by i have never encountered such problem in
VC++!
I tried doing the simplest test:
Create new solution -Win32 project...

In the main procedure I wrote this:
int i=-1;

And breakpoint on the next line.

The value of i is 0xffffff !!!

I tried writing singed int, the same thing happens..
Tried all of the data types, nada.

Can anyone explain this???

Yes.
You display debug information in HEX. The hex for -1 is 0xFFFFFFFF in 2's
complement.
Turn of HEX display for your debug information (e.g. from within the watch
window) and you should be fine.

Kind regards,
Bruno van Dooren MVP - VC++
http://msmvps.com/blogs/vanDooren
Apr 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Rade | last post by:
Following a discussion on another thread here... I have tried to understand what is actually standardized in C++ regarding the representing of integers (signed and unsigned) and their conversions....
2
by: REH | last post by:
If the is_modulo field of the numeric_limits class is true for signed integer types, can I assume that overflow for such types is defined behavior? If so, is the behavior the same regardless of...
6
by: Sona | last post by:
Hi, What is the difference between a signed 0x00 (NULL, or 0) and an unsigned 0x00? Can there be one? If I do the following: char var; var = 0x00; what should var hold? and if it was an...
2
by: Aire | last post by:
1. If a function defined as: void test_function(unsigned int a) { } Is "test_function(-256);" going to cause undefined behavior? 2. What's "a negative signed value wrapping"?
9
by: Fred Ma | last post by:
Hello, I've been trying to clear up a confusion about integer promotions during expression evaluation. I've checked the C FAQ and C++ FAQ (they are different languages, but I was hoping one...
9
by: dam_fool_2003 | last post by:
For int data type the default range starts from signed to unsigned. If we don't want negative value we can force an unsigned value. The same goes for long also. But I don't understand why we have...
10
by: tinesan | last post by:
Hello fellow C programmers, I'm just learning to program with C, and I'm wondering what the difference between signed and unsigned char is. To me there seems to be no difference, and the...
26
by: LuB | last post by:
This isn't a C++ question per se ... but rather, I'm posting this bcs I want the answer from a C++ language perspective. Hope that makes sense. I was reading Peter van der Linden's "Expert C...
7
by: somenath | last post by:
Hi All, I am trying to undestand "Type Conversions" from K&R book.I am not able to understand the bellow mentioned text "Conversion rules are more complicated when unsigned operands are...
39
by: Juha Nieminen | last post by:
I was once taught that if some integral value can never have negative values, it's a good style to use an 'unsigned' type for that: It's informative, self-documenting, and you are not wasting half...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
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,...

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.