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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:55:17+00:00 2026-05-12T09:55:17+00:00

I am investigating encoding of date information into a linear barcode that must be

  • 0

I am investigating encoding of date information into a linear barcode that must be as short as possible. One idea we have had is encoding date information rather than using the ASCII characters for the date numerals.

  1. The earliest date to be encoded is 01-JAN-2009
  2. Date must be encoded using printable ASCII characters
  • 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-12T09:55:17+00:00Added an answer on May 12, 2026 at 9:55 am

    If only the date matters (not the time):

     Take the date to be encoded.
     Subtract 1-1-2009 from it
     Get the amount of elapsed days.
    

    To encode this number as a printable sequence of ascii chars(ascii 48-127) do the following

    pseudo code:

     const int ASCIILOWRANGE = 48
     const int ASCIIHIGHRANGE = 126
     const char ASCIIENDMARKER = 127;
    
    
     String convertToAscii(int numberOfDays)
     {
           String output = "";
    
           while(numberOfDays>0)
           {
               output += (char) ASCIILOWRANGE + numberOfDays % (ASCIIHIGHRANGE-ASCIILOWRANGE);
               numberOfDays /= (ASCIIHIGHRANGE-ASCIILOWRANGE);
           }
           output += ASCIIENDMARKER ;
           return output;
     }
    
     //decoder
     int convertToDays(String ascii)
     {
          char rightmost;
          int numberOfDays = 0;
          while(ascii.length>0)
          {
           rightmost = ascii[0];
               if(rightmost == ASCIIENDMARKER ) break; //ready
    
               numberOfDays *= (rightmost - ASCIILOWRANGE) * (ASCIIHIGHRANGE-ASCIILOWRANGE);
               ascii = ascii.substr(1); //remove rightmost char from string
          }
          return numberOfDays ;
     }
    

    this way of encoding is the most dense. Since it encodes upto 96 days into the future in just 2 chars. 9216 days, in 3 chars, 884736 days in 4 chars.

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

Sidebar

Related Questions

Whilst investigating a memory leak I discovered that it was caused by calling NewRow()
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
While I was investigating a problem I had with lexical closures in Javascript code,
While investigating a reported problem with my site loading slowly, I came across an
We are investigating using CruiseControl.NET as both a Continues Integration build provider, as well
I am investigating the design of a work queue processor where the QueueProcessor retrieves
I'm investigating the differences between using log4net and System.Diagnostics.Trace for logging, and I'm curious
I'm investigating an annotation-based approach to validating Spring beans using spring modules . In
I am investigating a production system where there are several Windows services communicating with
I'm investigating using MSMQ for my team's new project but I need to know

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.