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

  • Home
  • SEARCH
  • 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 8218417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:47:11+00:00 2026-06-07T12:47:11+00:00

My question is in the following example what does val = val >> 2;

  • 0

My question is in the following example what does val = val >> 2; do? That is I believe it is division by 4.

int val = 12345678;
val = val >> 2;

Here is the background to this question.

I have a read from a water meter, say 12345678. The way our water meters work is the two right-hand digits are thrown away for the read, so 123456 is really the read. (There are reasons for throwing away the two right hand digits that have to do with how water flow makes the registers turn. That really has nothing to do with my question, though.)

Currently, we are taking 12345678 and dividing it by 100, using 4GL integer variables, so I’m not getting a decimal number. We are getting truncation we do not expect, and I am
trying to determine if bit shift would be better.

After the read is truncated to 123456, a delta is calculated using the last read (also truncated), and from that the consumption is generated.

I have C available to me in Informix 4GL, and I believe the best way to remove the lowest two digits would be to bit-shift right by 2. I believe that is the only way I am going to obtain — for example —

5 digit meter   12345 --> 123
6  "     "     123456 --> 1234
7  "     "    1234567 --> 12345

Thank you for tolerating a simplistic question. We’re trying to figure out a problem of how are endpoints — which talk to the meters — are programmed and what the data really means coming out of the endpoints.

  • 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-07T12:47:12+00:00Added an answer on June 7, 2026 at 12:47 pm

    Bit-shifting throws away the last two binary digits, not decimal digits. It is equivalent to integer division by four. You need to int-divide by 100 to throw away the last two decimal digits.

    101111000110000101001110bin = 12345678dec

    101111000110000101001110bin >> 2dec = 1011110001100001010011bin

    1011110001100001010011bin = 3086419dec

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

Sidebar

Related Questions

I have a question on the stream behavior, see the following example. What I
Check this example before reading the question - http://www.sqlfiddle.com/#!2/fcf3e/8 The following data comes from
I ask this question following the issue I raised here . The point is
I have a following question. We have an application that is a basically a
QUESTION ONE: In the following example, ive added a listener to the foundMic. My
I'm trying to implement the example code of the following question by using opencv
From the mysql certification guide's example questions ... question Will the following SQL statement
I created the following simple PL/SQL stored procedure example to ask a specific question.
I have taken the following object as an example: var questions = { 1:
While answering another question, I thought of the following example: void *p; unsigned x

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.