Algorithms Are Your Friend


Last year, I was approached by a client with an existing web application that stored the shipping details for large transoceanic shipping containers. They were in need of validation on a form that ran the ISO 6346 algorithm on the BIC Code or serial number for the container. Such code needs to be registered at the Bureau International des Conteneurs in Paris to ensure uniqueness worldwide. Using Javascript, I was able to add this validation to submit the form only after the ISO 6346 Algorithm was completed and the check number passed. Lets take a look at how this works, and why it is important.

Owner Code

The owner code consists of three capital letters of the Latin alphabet to indicate the owner or principal operator of the container.

Equipment Category Identifier

The equipment category identifier consists of one of the following capital letters of the Latin alphabet:

  • U for all freight containers
  • J for detachable freight container-related equipment
  • Z for trailers and chassis

Under the ISO code, then, only U, J, and Z are in useβ€”the reefer container is identified by means of the size type code.

Serial Number

The serial number consists of 6 numeric digits, assigned by the owner or operator, uniquely identifying the container within that owner/operator’s fleet.

Check Digit

The check digit consists of one numeric digit providing a means of validating the recording and transmission accuracies of the owner code and serial number.

Conversion Algorithm

To compute the check digit, the letters have to be converted to numbers. This is done in three steps:

Calculation Step 1

An equivalent numerical value is assigned to each letter of the alphabet, beginning with 10 for the letter A (11 and multiples thereof are omitted):

A B C D E F G H I J K L M
10 12 13 14 15 16 17 18 19 20 21 23 24
N O P Q R S T U V W X Y Z
25 26 27 28 29 30 31 32 34 35 36 37 38

The individual digits of the serial number keep their numeric value.

Calculation Step 2

Each of the numbers calculated in step 1 is multiplied by 2position, where position is the exponent to base 2. Position starts at 0, from left to right.

The following table shows the multiplication factors:

1. nbr 2. nbr 3. nbr 4. nbr 5. nbr 6. nbr 7. nbr 8. nbr 9. nbr 10. nbr
20 21 22 23 24 25 26 27 28 29
1 2 4 8 16 32 64 128 256 512
Calculation Step 3
  1. Sum up all results of Step 2
  2. Divide them by 11
  3. Round the result down to zero i.e. make the result a whole number (integer)
  4. Multiply the integer value by 11
  5. Subtract result of (iv) from result of (i): This is the check digit.

If the final difference is 10, then the check digit becomes 0. To ensure that this does not happen, the standard recommends that serial numbers should not be used which produce a final difference of 10; however, there are containers in the market which do not follow this recommendation, so handling this case has to be included if a check digit calculator is programmed.

Notice that step (ii) to (v) is a calculation of the remainder found after division of (i) by 11. Most programming languages have a modulo operator for this. Attention should be paid on how it is working in the language chosen; i. e. if it is giving back the decimal rest or the integer rest in order to get proper results. 11 is used as divisor because a container number has 11 letters and digits in total. In step 1 the numbers 11, 22 and 33 are left out as they are multiples of the divisor.

Example
C S Q U 3 0 5 4 3 8 Calc.
13 30 28 32 3 0 5 4 3 8
Γ— 1 2 4 8 16 32 64 128 256 512
13 60 112 256 48 0 320 512 768 4096 6185 [a]
b) Division by 11: 562.272…
c) Erase decimal digits: 562
d) Multiply by 11: 6182
a) minus d) = Check Digit: 3

 

Below is the Javascript code to create a custom “ISO6346Check”:

See the Pen ISO 6346 by Nathan Shumate (@nzshumate) on CodePen.

This was an exciting project to work on and opened my eyes to the complexities of international logistics and the role of technology in the industry.

admin

I am a developer and consultant based in Conway, Arkansas. I am constantly reading, writing, and experimenting with the latest in web technologies. When I am not doing that I am trying to find the perfect cup of coffee, looking for new hiking trails, or planning my next adventure.

You may also like

Comments are closed here.

About me

Nathan Shumate

Nathan Shumate

I am a developer and consultant based in Conway, Arkansas. I am constantly reading, writing, and experimenting with the latest in web technologies. When I am not doing that I am trying to find the perfect cup of coffee, looking for new hiking trails, or planning my next adventure.

Coffee Savings Calculator

Placeholder values show standard quantites of each ingredient for a flavored latte with a double shot of espresso. Adjust the values as needed to get accurate savings based on your consumption.


You have saved: {{ savings | currency }}

Instagram

Early morning workout, productive day at work, pizza πŸ• for dinner, hot tub πŸ›€ time with the wife and kiddo, now finishing off the day with this delicious craft brew. #good
Some light reading this morning.
Instagram
Instagram
Instagram
Instagram
On the way to food truck in Austin
I love the artwork on this bottle 🍷
Instagram
Instagram
One week of marriage. Heading out on a winery tour 🍷 ❀️ πŸ‘° 🎩
Sculpted in 1775, the Rose Window is considered to be one of the finest examples of baroque architecture in North America.  Its sculptor and significance continue to be a mystery.  Folklore credits Pedro Huizar, a carpenter and surveyor from Spain, with carving the famous window as a monument to his sweetheart, Rosa.  Tragically, on her way from Spain to join him, Rosa was lost at sea.  Pedro then completed the window as a declaration of enduring love.