![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
11 years old
Join Date: Nov 2007
Posts: 79
Rep Power: 1
![]() |
Casting signed int to unsigned int?
I know I could use simple C casts (unsigned int uint_fld = (unsigned int) ivar;) but I'm not sure if I should use some of the handy casting functions (unsigned int uint_fld = dynamic_cast<unsigned int>(ivar);). Which should I chose?
sidequestion: I have countlessly just casting something unsigned through c++ Syntax (Toggle Plain Text)
|
|
|
|
|
|
#2 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 498
Rep Power: 4
![]() |
Re: Casting signed int to unsigned int?
Most c++ pureists would say that it is NOT appropriate for c++. IMO (for what its worth) I think it depends -- in your example it would be ok, but in more complex situations it would not. If you do use the c-style castings you must make sure you absolutely KNOW what you are doing because the compiler will simply assume you are correct -- no error checking. The compiler will produce warnings or error with c++ casts.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Correlating an int with a string | truBlu | C++ | 6 | Oct 12th, 2007 10:18 AM |
| Passing int arrays as arguments... | Soulstorm | C++ | 9 | Sep 3rd, 2007 8:13 AM |
| splitting up char and converting to int | jokr004 | C++ | 10 | Jul 20th, 2007 4:09 PM |
| Question regarding Malloc() and Type casting | sparda | C | 6 | Sep 29th, 2005 4:12 AM |
| Storing Negative Numbers in unsigned ints | aznluvsmc | C | 9 | Aug 22nd, 2005 10:09 PM |