Check Digit calculation (IBAN) – MOD 97

Some times I am amused how problems, that looked like huge pain, can be solved in few lines of code using basic math algorithms learned at elementary school. We were adding IBAN number verification which requires mod 97 calculation on number with 18 digits or more. First instinct was to just execute it directly as n%97Then it became clear that integer variable can't be used. Than I start thinking about some other type or class, that can be magically used instead, but that just didn't seemed as right way to go. OK, I had to think it over. Solution that I come up is using a "traditional long division algorithm":

94 / 7 = 13 R 3
7
--------
24
21
--------
3

So here it is simple and efficient, c# code, but can easily be adapted for any programming language:

string str_digits = "12345678901234567890";
long mod_value = 0;
for (int i = 0; i < str_digits.Length; i++)
{
    long digit = str_digits[i] - '0';
    mod_value = ((mod_value * 10) + digit) % 97;
}
Posted in Programming | Tagged , , | 2 Comments

New site design

Actually, it is whole new site started from scratch.

Site is now based on wordpress used as CMS. I have followed five simple rules described here, made couple simple adjustments to wordpress template and Voilà! New site is here :)

I had a little hand work adding support for Gravatar , but with great community support it was done in minutes. Adding Gravatars couldn't be easier, in the Choice theme, alter your comments.php with following line:

<?php if(function_exists(’get_avatar’)){ echo get_avatar($comment, ‘50’);} ?>

While we are at plugins, I also added SimpleModal Contact Form (SMCF) plugin which looks great, you can see it here in action.

Site content is still work in progress, as well as my long awaited first official software release, but please bear with me over the next few months.

Posted in Web | Tagged , , , | Leave a comment

First official post

Louis, I think this is the beginning of a beautiful friendship

Famous last words in movie Casablanca, I hope that those words are nice introduction for my first development blog.
Play it again

See you soon :)

Posted in News | Tagged | 1 Comment