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 8154213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:15:58+00:00 2026-06-06T16:15:58+00:00

I have one WORD variable in my program. WORD hour; But when I compare

  • 0

I have one WORD variable in my program.

WORD hour;

But when I compare It

if(hour>=0 && hour<=18)
{
    hour+=6;
}

It will generate warning
[Warning] comparison is always true due to limited range of data type

I am using Dev-C++ as IDE.

  • 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-06T16:16:00+00:00Added an answer on June 6, 2026 at 4:16 pm
    if(hour>=0 && hour<=18)
    

    I think the warning is for the comparison hour >=0 which is always true for hour is of type WORD which is a typedef of unsigned short (usually) which means hour is always greater than or equal to 0:

     typedef unsigned short WORD;
    

    On MSVC++ it is how WORD is defined, check your compiler if it is unsigned or not. If it unsigned1, then hour >=0 is obviously true for all possible values of hour. In that case, you need to write just this:

    if(hour<=18) //(hour >= 0) is implied by its type
    {
        hour+=6;
    }
    

    1. Note that it doesn’t matter whether is unsigned int or unsigned short. As long as it is unsigned, hour >=0 will be true for all possible values of hour.

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

Sidebar

Related Questions

Let's say I have this variable: word = habit which command in VBA will
I have one method with one letter(string\char?) as argument and one word active at
Hi I have a text file (one word per line) and I want to
I have an input field which has a placeholder text. I want one word
Sorry guys, didn't know how to word this one. Still learning jquery and have
I have a Visual Basic program in Excel which opens Word documents and copies
I have two files, in one I declare the variable SEED as such: ;file1.asm
Does a set of functions doing exactly one word but differing in the name
Possible Duplicate: Split into two variables? I have a variable that will output two
I have a variable: $form.attr('action') that contains one of the following: action=/Administration/Contents/JsonCreate action=/Administration/Contents/JsonEdit action=/Administration/Contents/JsonDelete

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.