Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Adding hexadecimal values in c++

Adding hexadecimal values in c++

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++tutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    ledallam
    wrote on last edited by
    #1

    Hi, I am working with Serial communication in VC++. I have a message in this format: Message: "0XD07889ABCDEF47". It is in hexadecimal format. 0XD0 - Header 7889ABCDEF - Data 47 - Checksum I have to compute the checksum using the formula (~((Header+Data) & 0X7F) & 0X7F)) What data type can I use to store the Message? How do I compute the checksum using C++ code? I am new to this exercise. Can anyone please guide me? Thanks Madhavi

    K 1 Reply Last reply
    0
    • L ledallam

      Hi, I am working with Serial communication in VC++. I have a message in this format: Message: "0XD07889ABCDEF47". It is in hexadecimal format. 0XD0 - Header 7889ABCDEF - Data 47 - Checksum I have to compute the checksum using the formula (~((Header+Data) & 0X7F) & 0X7F)) What data type can I use to store the Message? How do I compute the checksum using C++ code? I am new to this exercise. Can anyone please guide me? Thanks Madhavi

      K Offline
      K Offline
      Kreatief
      wrote on last edited by
      #2

      I think an integer in the form \x0D0 should do the job. EDIT: Just checked it! Do it like that: int whatever='\x20'; int whatever2='\x32'; whatever+=whatever2; Check for (decimal) 82, and you see its correct! DKT

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups