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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:23:30+00:00 2026-05-26T02:23:30+00:00

I am converting a hex 0xE0 to BCD. When I do this I am

  • 0

I am converting a hex 0xE0 to BCD. When I do this I am getting back a 64. I know this is completely wrong and maybe it’s something in my C++ code, but 64 just doesn’t sound correct. Any ideas? Is 0xE0 a special case? (0xE0 is 224 in decimal.)

Here is part of my code:

unsigned char Hex2BCD(unsigned char param)
{   unsigned char lo;
    unsigned char hi;
    unsigned char val;
    unsigned char buf[10];

hi = param/ 10;
lo = param- (hi * 10);

val= (hi << 4) + lo;
return val;
}
  • 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-05-26T02:23:31+00:00Added an answer on May 26, 2026 at 2:23 am

    my idea is that your code for converting to BCD is buggy. it does not do what it is supposed to, thus the wrong result you are observing.

    aside from this joke: 0xe0 if stored in signed char is a negative number. that could play nasty tricks on you if you don’t pay special attention on the sign of temporary variables you are using while computing the result.

    edit: now that you posted some code, it is clear that, although you compute the right value for the first digit into lo, you need another step in order to get the right value into hi.

    using 0xe0 as input, you are actually computing (22<<4) + 4 = 356 = 0x164 instead of (2<<8)+(2<<4)+4 = 548 = 0x224.

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

Sidebar

Related Questions

I am converting hex-string into a dateformat... I am getting wrong date time with
Converting my current code project to TDD, I've noticed something. class Foo { public
I'm having toubles with converting triple HEX color codes in an RGB color code
I've googled this but possibly typing in the wrong thing. I see hexadecimal numbers
I know- there are lots of topics concerning this, BUT even though I did
This is a follow on from: Python - Converting Hex to INT/CHAR I now
This HMACSHA1 code below works for converting Password and Message to AFF791FA574D564C83F6456CC198CBD316949DC9 as evidence
Any hints on parsing / converting / operating on hex values in c# ?
I'm taking a hex color value received as a string and converting it to
I've got the code below to pull hex values from a database and create

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.