Silverlight for everybody

June 22, 2008 on 5:32 pm | In Silverlight | No Comments

image My fist text for a Polish computer magazine NEXT hast just been published. It is called “Silverlight for everybody”. New publisher new challenge. I hope for a long lasting collaboration. In a mean time you can check my GeoCodedCalcualtor. A simple piece of Silverlight app that calculates the degrees, minutes, seconds form of latitude, longitude notation to a numeric notation and shows the translated coordinates using Google Static Maps Api. Enjoy!

Remember to brake your egg at the small end*

June 9, 2008 on 9:53 pm | In Clarion | No Comments

Sometimes the interoperability between .NET and Win32 could by a pain in the ass. Especially in places you don’t expect it to be. I’ve worked recently on a cryptography algorithm. I had the source code in Clarion and all I had to do was to implement it in C#. No problem I guessed. But… The Clarion algorithm used pointers extensively. I have worked with byte arrays. I read the text as a char array and I copied the bytes into long variables using a binary shift. Lets say we have a

string s = "abcd";

Its something like this:


If we try to interpret this as a uint variable:

uint ui = (uint)((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]);

we will get something like this number 1633837924.

Lets look at this from the other side. Our string goes direct into memory:


Using Win32 compiler we want to read it to a ulong variable x from a px address. In Clarion the code to do this will look like this:

x &ulong

long px

x &= (px)

What do we get in x?


Hmm, variable ui in C# and x in Wind32 are not the same. Why? Because Intel is using a small endian way to store the numbers. So it means that the highest byte is saved at the right side and the lowest at the left. Like this (small endian):


and not (big endian)


* In Jonathan Swift’s Gulliver’s Travels the Little Endians broke their eggs at the small end, where the Big Endians broke theirs at the large end. And the ones were not very fond of the others ;-)

Powered by WordPress with Pool theme design by Borja Fernandez.
Text © Marcin Kawalerowicz. Hosting CODEFUSION.