Jump to content
  • Advertisement
Sign in to follow this  
ZergUser

C++

This topic is 3583 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

One of the posts here mentions that unsigned char objects are guaranteed never to have trap values. What is a trap value? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
I believe what he means by "trap values" is that the unsigned char is guaranteed to not hold any value which is considered illegal for its type or perhaps for a type conversion. That is just a guess,though but the main reason I would use an unsigned char is for instance if casting to an integer and I expect the value to be positive (sign extension will occur on a signed char if the high bit is set). Another thing for instance if passing a signed char to an isspace() function on some implementations of the function it may cause an access violation if the character is higher than value 127 because it is used to index into an array but the conversion makes it negative!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!