Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: Why do they...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 10 Topic 44216 of 48417
Post > Topic >>

Re: Why do they cast it twice?

by "Bo Persson" <bop@[EMAIL PROTECTED] > Mar 30, 2008 at 01:41 PM

ManicQin wrote:
>> Not knowing the type of _Val, I can't say, but in general,
>> casting through an unsigned type guarantees a positive value in
>> the long (unless the positive value won't fit).
>
> The same behavior returns when _Val is long and short.
>
>> Yes, the idea is to get the value unsigned, to avoid sign extension
>> for hex and octal representation.
>>
>
> So why not just cast it directly to unsigned long... why the DOUBLE
> cast...
> I'm referring to the line (long)(unsigned short)_Val
> besides ... when casting to unsigned and then to signed isn't the
> result will be signed again?
>

It will not be the same if the short value is negative.


Bo Persson
 




 10 Posts in Topic:
Why do they cast it twice?
ManicQin <ManicQin@[EM  2008-03-30 01:06:45 
Re: Why do they cast it twice?
James Kanze <james.kan  2008-03-30 03:46:36 
Re: Why do they cast it twice?
"Bo Persson" &l  2008-03-30 13:21:09 
Re: Why do they cast it twice?
ManicQin <ManicQin@[EM  2008-03-30 04:32:18 
Re: Why do they cast it twice?
"Bo Persson" &l  2008-03-30 13:41:36 
Re: Why do they cast it twice?
Juha Nieminen <nospam@  2008-03-30 16:43:12 
Re: Why do they cast it twice?
"Daniel T." <  2008-03-30 13:06:34 
Re: Why do they cast it twice?
ManicQin <ManicQin@[EM  2008-03-31 00:53:40 
Re: Why do they cast it twice?
tommy.hinks@[EMAIL PROTEC  2008-03-31 13:50:02 
Re: Why do they cast it twice?
Triple-DES <DenPlettfr  2008-03-31 23:33:49 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 9:30:55 CST 2008.