Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8678937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:50:53+00:00 2026-06-12T20:50:53+00:00

I just ran into something very awkward while working with HRESULT return values, it

  • 0

I just ran into something very awkward while working with HRESULT return values, it seems that success is 0 and failure is 1. What is the logic behind this?

I actually tried if(!hr) and failed miserably, wasting an hour of my life until I figured out the actual success retval is 0. I would like to call the person who thought of this an idiot, but I’ll try to cool down – hoping someone will shed some light on this convention.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:50:54+00:00Added an answer on June 12, 2026 at 8:50 pm

    The original purpose of HRESULTs was to formally lay out ranges of error codes for both public and Microsoft internal use in order to prevent collisions between error codes in different subsystems of the OS/2 Operating System.

    That’s why, value of 0 (of highest bit of HRESULT) means ‘no error’, that is, success.

    But one should be careful, since it is possible for HRESULT to have highest bit set to 0 and other bits set different from 0. That means, the check if(0 == hr) { ... } may not work for some successful cases. The correct way to check for success is if(0 <= hr) { ... }.

    Wikipedia has more detailed information.

    SUCCEEDED and FAILED macros can be used to avoid mistakes when dealing with HRESULT values. if(0 <= hr) { ... } and if(SUCCEEDED(hr)) { ... } are basically the same things.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just ran into something in Visual Studio 2010 RC that wasn't previously happening
I just started playing around with threading today and I ran into something that
I just ran into a conflict while working in SVN, and I find myself
I just ran into something very strange, and was just wondering if I was
I'm working on some legacy code and I ran into something that I'm not
I just ran into this issue while making a GET request to a node.js
So I ran into something interesting that I didn't realize about the ternary operator
I ran into what seemed a mysterious bug this morning that I feel very
Just started working with android and ran into a small problem. I am have
I just ran into something weird. I have two JSON arrays which holds different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.